I would like to split this string:
C:\RCOUNT2013\2013_Extracted\Weekly ODEN Notices Report.12-28-2013.2013-12-29 07-20-51.pdf.log.0
on the \
. What would the regex be?
string.split("\\ \") // ?
I would like to split this string:
C:\RCOUNT2013\2013_Extracted\Weekly ODEN Notices Report.12-28-2013.2013-12-29 07-20-51.pdf.log.0
on the \
. What would the regex be?
string.split("\\ \") // ?
In regex-land, a \
is an escape character, so to obtain a literal \
we need to escape it: \\
. However, in Java strings, \
is also an escape character, so we need to escape each \
a second time, resulting in \\\\
. Therefore, this is what you want:
str.split("\\\\")
split("\\\\")
Double-escaping "\"
The regex would be "\\\\"
In the source code: "\\\\"
After compiling, the string is: "\\"
And the regex parser interperets this as look for a \
, So it matches one backslash '\'