in reply to Re^9: Parser Performance Question (Atomic grouping)
in thread Parser Performance Question
I had completly forgotten about the atomic match :). I reread the documentation (because I wasn't sure what it does exactly), and it shows that it is equivalent to the possessive quantifiers. So in the spirit of TIMTOWTDI:
use strict; use warnings; use feature 'say'; use Data::Dump qw( pp ); my @strs = qw( "..\\".. "abc" "a\"bc" "a\\\\bc" "a\" ); my %re = ( LanX => qr/ " (?> \\\\ | \\" | [^"] )* " /x, Eily => qr/ " (?: [^"\\] | \\. )* " /x, Poss => qr/ " (?: \\\\ | \\" | [^"] )*+ " /x, ); for my $str (@strs) { say "\nTesting: <$str> = ", pp ($str); $str =~ /$re{$_}/ and say "$_ found $&" or say "$_ found nothing" for keys %re; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: Parser Performance Question (Atomic grouping)
by LanX (Saint) on Oct 06, 2017 at 13:40 UTC | |
by Eily (Monsignor) on Oct 06, 2017 at 14:03 UTC | |
|
Re^11: Parser Performance Question (Atomic grouping)
by songmaster (Beadle) on Oct 20, 2017 at 01:37 UTC |