I am trying to create a Regex expression with a numerical reference (to a capture group) in a neglected set.
Something like this:
(["'])([^\1]*)(\1)
Basically it matches all strings with either a single or double quote surrounding it. For example:
"foo bar" "foobar"
→ "foo bar"
and "foo bar"
The reason I can't just use the (["'])([^"']*)(\1)
is the following scenario:
"foo bar's" "foobar"
Instead of matching "foo bar's"
and "foobar"
it matches " "
.
How can I use numerical reference in a neglected set? If I can't how can I overcome this issue?