utils_gsub_if_found {podcleaner} | R Documentation |
Conditionally amend character string vector.
Description
Searches for specified pattern in provided character string vector. If found, substitutes all occurrences of an alternative pattern in an alternative character string and returns the output. If not return the default character string provided.
Usage
utils_gsub_if_found(
regex_filter,
string_filter,
regex_search,
string_replace,
string_search,
default,
ignore_case_filter,
ignore_case_search
)
Arguments
regex_filter |
Pattern to look for provided as a character string regex. |
string_filter |
Character string vector to search into for the pattern
provided in |
regex_search |
Alternative pattern provided as a character string regex
to look in the alternative character string provided in |
string_replace |
Substitution character string for matches of
|
string_search |
Alternative character string to search into for the
pattern provided in |
default |
Character string returned if pattern provided in |
ignore_case_filter |
Boolean specifying whether case should be ignored ( |
ignore_case_search |
Boolean specifying whether case should be ignored ( |
Value
A character string vector.
Examples
## Not run:
utils_gsub_if_found(
"^glasgow", c("glasgow-entrepreneurs", "aberdeen-entrepreneurs"),
"(?<=-).+$", "merchant", "edinburgh-entrepreneurs", "pattern not found",
TRUE, TRUE
)
## End(Not run)