replace_urls_with_placeholders: Replace URLs in a sentence with placeholders

View source: R/url_helpers.R

replace_urls_with_placeholdersR Documentation

Replace URLs in a sentence with placeholders

Description

Detects and replaces protocol-style links (e.g., ⁠http://⁠, ⁠https://⁠, ⁠ftp://⁠) in a given sentence with unique placeholders like ⁠__URL1__⁠, ⁠__URL2__⁠, etc. This is useful for preparing text for translation or further processing while preserving original URLs.

Usage

replace_urls_with_placeholders(sentence)

Arguments

sentence

A character string potentially containing one or more URLs.

Value

A list with two elements:

text

The input sentence with URLs replaced by placeholders.

urls

A character vector of the extracted URLs.


polyglotr documentation built on June 8, 2025, 11:12 a.m.