0

i want to match text encapsulated by a character, apostrophe for example. This can be achieved with the following regex:

/'[^']*'/

If i want to add other characters, like |pipe|, i can do it like this:

/'[^']*'|\|[^\|]*\|/

But i want it to be more "dynamic"/i want it to be easier to add more characters, so i tried the following:

/([\|'])[^\1]*\1/

But it does not recognize the \1 as the first capturing group, it recognizes it as an escaped 1
How can i change this behavior so that [^\1] is taken as "match any character except the one from capturing group 1"?

Thanks in advance!

0 Answers0