I'm trying to write a parser that uses two characters as token boundaries, but I can't figure out the regular expression that will allow me to ignore them when I'm regex-escaping the whole string.
Given a string like:
This | is || token || some ||| text
I would like to end up with:
This \| is || token || some \|\|\| text
where all of the | are escaped unless there are two of them together.
Is there a regular expression that will allow me to escape every | that isn't in a pair?