in reply to Re^8: Parser Performance Question (updated)
in thread Parser Performance Question
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 ); for my $str (@strs) { say "\nTesting: <$str> = ", pp ($str); $str =~ /$re{$_}/ and say "$_ found $&" or say "$_ found nothing" for keys %re; }
Testing: <"..\"..> = "\"..\\\".." LanX found nothing Eily found nothing Testing: <"abc"> = "\"abc\"" LanX found "abc" Eily found "abc" Testing: <"a\"bc"> = "\"a\\\"bc\"" LanX found "a\"bc" Eily found "a\"bc" Testing: <"a\\bc"> = "\"a\\\\bc\"" LanX found "a\\bc" Eily found "a\\bc" Testing: <"a\"> = "\"a\\\"" LanX found nothing Eily found nothing
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Parser Performance Question (Atomic grouping)
by Eily (Monsignor) on Oct 06, 2017 at 12:37 UTC | |
by LanX (Saint) on Oct 06, 2017 at 13:40 UTC | |
by Eily (Monsignor) on Oct 06, 2017 at 14:03 UTC | |
by songmaster (Beadle) on Oct 20, 2017 at 01:37 UTC |