for special character, I think escaping with \\
in R will do the trick. Here is an example where \\-
match -
gsub("\\-", "+", "re-entry")
#> [1] "re+entry"
gsub("[^a-zA-Z0-9&\\-]", "+", "re-entry*")
#> [1] "re-entry+"
for special character, I think escaping with \\
in R will do the trick. Here is an example where \\-
match -
gsub("\\-", "+", "re-entry")
#> [1] "re+entry"
gsub("[^a-zA-Z0-9&\\-]", "+", "re-entry*")
#> [1] "re-entry+"