mazz0 :
How can I find and operate on a character in a string only if it isn't escaped (ie proceeded by an odd number of another character)?
Example:
Desired character: |
Escape character: \
|
should be found (and operated on, for example split)
\|
should not
\\|
should
\\\|
should not
revo :
Use a negative a lookbehind to define a boundary:
(?<!\\)(?:\\\\)*\|
See live demo here
Taking care of backslashes in Java, above regex would be:
(?<!\\\\)(?:\\\\\\\\)*\\|