alphaOnly.RdFrom a text string, keep ASCII letters, numbers, as well as "'", " ", "_" "(", ")", "-", and "+". For maximum compatability with the cross-platform file-naming standard. Obliterates all characters that migth be mistaken for shell symbols, like "^", "$", "@" and so forth.
alphaOnly(x, also)cleaned text string
Removes trailing spaces.
This version allows internal spaces in the string, by default. The also argument can be used to eliminate spaces or other hated symbols.
x <- c("[]kansas(city) Missouri", "percent%slash/",
"\back{squiggle}_under(paren)", "*star-minus+plus")
alphaOnly(x)
#> [1] "kansas(city) Missouri" "percentslash"
#> [3] "acksquiggle_under(paren)" "star-minus+plus"
alphaOnly(x, also = c(" " = "_", "+" = "_"))
#> [1] "kansas(city)_Missouri" "percentslash"
#> [3] "acksquiggle_under(paren)" "star-minus_plus"
alphaOnly(x, also = c("(" = "[", ")" = "]"))
#> [1] "kansas[city] Missouri" "percentslash"
#> [3] "acksquiggle_under[paren]" "star-minus+plus"