str_singleize: Remove back-to-back duplicates of a pattern in a string.

Description Usage Arguments Value See Also Examples

View source: R/singleize.R

Description

If a string contains a given pattern duplicated back-to-back a number of times, remove that duplication, leaving the pattern appearing once in that position (works if the pattern is duplicated in different parts of a string, removing all instances of duplication). This is vectorized over string and pattern.

Usage

1
str_singleize(string, pattern)

Arguments

string

A character vector.

pattern

The pattern to look for.

The default interpretation is a regular expression, as described in stringi::about_search_regex.

To match a without regular expression (i.e. as a human would), use coll(). For details see stringr::regex().

Value

A character vector.

See Also

Other removers: str_remove_quoted(), str_trim_anything()

Examples

1
2
3
4
str_singleize("abc//def", "/")
str_singleize("abababcabab", "ab")
str_singleize(c("abab", "cdcd"), "cd")
str_singleize(c("abab", "cdcd"), c("ab", "cd"))

strex documentation built on April 18, 2021, 9:06 a.m.