morgon has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am trying to construct a regex that extracts the string beween two quotes with the complication that that string may contain backslash-escaped quotes.
To illustrate:
I hope that is understandable...my $rexeg = ???? # this is what I am after my ($m1) = '"hubba bubba"' =~ $regex; print "ok\n" if $m1 eq 'hubba bubba'; # should print "ok" my ($m2) = '"hubba \"bubba\""' =~ $regex; print "ok\n" if $m2 eq 'hubba "bubba"'; # should also print "ok"
I tried to do this with negative lookbehinds, but I attempt failed with "Variable length lookbehind not implemented", so am looking for some help here.
Many thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex for strings with escaped quotes
by haukex (Archbishop) on Feb 12, 2019 at 15:13 UTC | |
by morgon (Priest) on Feb 12, 2019 at 15:52 UTC | |
by haukex (Archbishop) on Feb 12, 2019 at 15:55 UTC | |
by morgon (Priest) on Feb 12, 2019 at 16:35 UTC | |
by haukex (Archbishop) on Feb 12, 2019 at 16:47 UTC | |
| |
by morgon (Priest) on Feb 12, 2019 at 15:17 UTC | |
by haukex (Archbishop) on Feb 12, 2019 at 15:19 UTC | |
by morgon (Priest) on Feb 12, 2019 at 15:24 UTC |
Back to
Seekers of Perl Wisdom