![]() |
|
There's more than one way to do things | |
PerlMonks |
Re^5: regex for strings with escaped quotesby haukex (Archbishop) |
on Feb 12, 2019 at 16:47 UTC ( #1229821=note: print w/replies, xml ) | Need Help?? |
The regex is:
which contains no capturing groups, hence $1 isn't populated. In my first bit of code, in the regex I added an extra set of parentheses, /($RE{delimited}{-delim=>'"'})/, so there is a capturing group there. That's the equivalent of:
Alternatively, you can take the first regex above and just change the non-capturing group (?:...) that surrounds the entire expression into a capturing group:
Or, since you said you wanted to capture the stuff between the quotes, change that non-capturing group into a capturing one:
Plus, there's a bunch of simplifications that could be made to the first regex above anyway (really just removing unnecessary groups):
and just add capturing groups to that as needed.
In Section
Seekers of Perl Wisdom
|
|