Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Parser Performance Question (updated)

by Eily (Monsignor)
on Oct 06, 2017 at 01:44 UTC ( [id://1200786]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Parser Performance Question (updated)
in thread Parser Performance Question

The last two are still incorrect, as q< \\" > will be parsed as an escaped quote. /" (?: [^"\\] | \\. )* "/sx is the bestest solution :-P

Edit: except when I'm an idiot and confuse (?= for (?:

Replies are listed 'Best First'.
Re^5: Parser Performance Question (updated)
by LanX (Saint) on Oct 06, 2017 at 02:08 UTC
    > q< \\" > will be parsed as an escaped quote

    I don't understand, it IS an escaped quote and it works for me:

    DB<175> $re = qr/ " (?: \\\\ | \\" | [^"] )* " /x; DB<176> p $a= q<x "..\\".." x> x "..\".." x DB<177> $a =~ /$re/; print $& "..\".."

    update

    maybe you should show us how you'd escape a double-quote.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Meh, this will teach me about posting when I can't test. I meant q< \\\\" >; but thought the \ wouldn't escape the next one. The case where the \ just before the " is litteral because escaped, so it can't escape the ".

      use v5.20; use Data::Dump qw( pp ); my $str = <<STR; " .. \\\\" .. " STR print $str; my %re = (LanX => qr/ " (?: \\\\ | \\" | [^"] )* " /x, Eily => qr/ " (?: [^\\] | \\. )* " /x); $str =~ /$re{$_}/ and say "$_ found $&" for keys %re;
      " .. \\" .. " Eily found " .. \\" .. " LanX found " .. \\"

        >
        " .. \\" .. " Eily found " .. \\" .. " LanX found " .. \\"

        Well, you proved that my version is correct and yours doesn't work.

        :p

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1200786]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 20:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found