Requires a RegEx that matches only one instance of a pipe symbol
3 answers
You avoid yours pipe
wrongly. You need to use backslash
, not slash
. Also, you also need to use negative look-behind
so that the pipe is last
not matched, which probably shouldn't precede the pipe, but shouldn't follow it: -
(?<!\|)\|(?!\|)
Generally, I prefer to use a character class rather than escaping when I want to match a metacharacter regex class: -
(?<![|])[|](?![|])
But, that's my taste.
+5
source to share