-1

How do I match a pair of double pipes (i.e. || text ||), while checking the content between the pipes for a singular pipe?

So, || text || matches " text ", while || spoiler2|spoiler|| matches " spoiler2|spoiler".

I've tried \|\|([^\|]+)\|\|, but that only matches the content without any further pipes between the two pipes.

Ildar Akhmetov
  • 1,331
  • 13
  • 22
Alex
  • 1
  • 3

1 Answers1

0

You can use a negative lookahead to ignore a pattern:

\|\|((?!\|\|).+)\|\|

The (?!\|\|) means to not match a || string.

Simon Doppler
  • 1,918
  • 8
  • 26