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:
Use a negative a lookbehind to define a boundary:
(?<!\\)(?:\\\\)*\|
See live demo here
Taking care of backslashes in Java, above regex would be:
(?<!\\\\)(?:\\\\\\\\)*\\|