I have a large amount of data where the delimiter is a backslash. I'm processing it in R and I'm having a hard time finding how to split the string since the backslash is a metacharacter. For example, a string would look like this:
1128\0019\XA5\E2R\366\00=15
and I want to split it along the \
character, but when I run the strsplit command:
strsplit(tempStr, "\\")
Error in strsplit(tempStr, "\\") :
invalid regular expression '\', reason 'Trailing backslash'
When I try to used the "fixed" option, it does not run because it is expecting something after the backslash:
strsplit(tempStr, "\", fixed = TRUE)
Unfortunately, I can't preprocess the data with another program because the data is generated daily.
Your line of code is (though you don't say it explicitly):
strsplit(tempStr, "\\")
and should be
strsplit(tempStr, "\\\\")
This will be read as "\\", which the regular expression will understand as a "\".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With