0

I'm looking for a regex that works in Javascript and emulates the double bar combinator for css rules.

The way double bar works:

  • all entities are optional
  • each entity can can appear at most once
  • at least one of them must be present
  • they may appear in any order

I found this answer which works perfectly except it doesn't work in Javascript

I spent a while trying to reformulate it to make it work in Javascript but I haven't had any luck.

^(?:(?:(?!\1)()|\1 )(?:(?!\2)()fat|(?!\3)()cat)){1,2}$

Here is a link to the regex (Python) that shows it working as intended

Here is a link to the same regex to show it doesn't work in Javascript

tleef
  • 3,516
  • 1
  • 24
  • 34

0 Answers0