I'm doing some batch string clean up and a lot of the entries look like this:
"ABC\Company Co."
Which causes weird errors, and I can't seem to remove the backslash.
For example, try entering this into your console:
gsub("BLAH", "", "BLAH\WHAT")
and you get:
Error: '\W' is an unrecognized escape in character string starting ""BLAH\W"
I know that it's thinking \W
is a command.. I'm actually suprised that gsub's 'interpreting' x
, since x
is just the string I want to sub out. I don't get why gsub cares what's actually in x
, just that it should replace "BLAH"
with "" within "BLAH\WHAT"
...
The obvious solution would be to remove the \ from the string ahead of time.
gsub("\\", "", "BLAH\WHAT")
But then you get the exact same error message!
Thoughts? Thanks!