| str_trim_anything {strex} | R Documentation |
The stringi and stringr packages let you trim whitespace, but
what if you want to trim something else from either (or both) side(s) of a
string? This function lets you select which pattern to trim and from which
side(s).
str_trim_anything(string, pattern, side = "both")
string |
A character vector. |
pattern |
A string. The pattern to be trimmed (not interpreted as
regular expression). So to trim a period, use |
side |
Which side do you want to trim from? |
A string.
Other removers: str_remove_quoted,
str_singleize
str_trim_anything("..abcd.", ".", "left")
str_trim_anything("-ghi--", "-")
str_trim_anything("-ghi--", "--")