strip_invalid_chars {assertive.strings} | R Documentation |
Removes invalid characters from a string, leaving only digits.
strip_invalid_chars(x, invalid_chars, char_desc = gettext("invalid")) strip_non_alphanumeric(x) strip_non_numeric(x, allow_x = FALSE, allow_plus = FALSE)
x |
Input to strip. |
invalid_chars |
A regular expression detailing characters to remove. |
char_desc |
A string describing the characters to remove. |
allow_x |
If |
allow_plus |
If |
A character vector of the same length as x
, consisting of
strings without the characters detailed in the invalid_chars
.
## Not run: strip_invalid_chars( " We're floating\tin space\n\n\n", "[[:space:]]", "whitespace" ) strip_non_numeric(" +44 800-123-456 ", allow_plus = TRUE) #Inputs such as factors as coerced to character. strip_non_alphanumeric(factor(c(" A1\t1AA.", "*(B2^2BB)%"))) ## End(Not run)