morgon has asked for the wisdom of the Perl Monks concerning the following question:
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.
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.
|Replies are listed 'Best First'.|
Re: regex for strings with escaped quotes
by haukex (Bishop) on Feb 12, 2019 at 15:13 UTC