I have a lot of data where the delimiter is a backslash. I process it in R, and it's hard for me to find how to split a string, since the backslash is a metacharacter. For example, the line would look like this:
1128\0019\XA5\E2R\366\00=15
and I want to split it along the character \, but when I ran the strsplit command:
strsplit(tempStr, "\\")
Error in strsplit(tempStr, "\\") :
invalid regular expression '\', reason 'Trailing backslash'
When I try to use the "fixed" parameter, it does not start because it expects something after the backslash:
strsplit(tempStr, "\", fixed = TRUE)
Unfortunately, I cannot pre-process the data with another program, because the data is generated daily.
source
share