I have a field of strings in a data frame all similar to:
\"Young Adult – 8-9\"\"
where the inner single \" is what I want to repl
You do not need to escape a double quote in a regular expression. Just use "\""
or '"'
to match a single double quote.
s = "Young Adult – 8-9\""
s
[1] "Young Adult – 8-9\""
gsub("\"", "", s)
[1] "Young Adult – 8-9"
gsub('"', "", s)
[1] "Young Adult – 8-9"
See this IDEONE demo
NOTE: Since you want to remove some literal text, you do not even need a regex, use fixed=TRUE
argument to speed up the operation:
gsub('"', "", s, fixed=TRUE)