Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: regex compilation

by AnomalousMonk (Archbishop)
on Feb 12, 2019 at 20:29 UTC ( [id://1229839]=note: print w/replies, xml ) Need Help??


in reply to Re: regex compilation
in thread regex compilation

FWIW, single-quoted regex notation gets you closer (update: than double-quoting) to the desired final form, but still not all the way and there are some pitfalls. Better, IMHO, to stick to qr//. (BTW: morgon: It's not necessary to escape a  " (double-quote) in a qr// expression.)

File rx_qr_qq_q_1.pl:

use warnings; use strict; my $rx_qr = qr/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my $rx_qq = qq/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; my $rx__q = q/(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))/; print qq{raw qr: $rx_qr \n}; print qq{qr/qq/: }, qr/$rx_qq/, "\n"; print qq{qr/q/ : }, qr/$rx__q/, "\n";
Output:
c:\@Work\Perl\monks\morgon>perl rx_qr_qq_q_1.pl raw qr: (?-xism:(?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\")))) qr/qq/: (?-xism:(?:(?|(?:")([^\"]*(?:\.[^\"]*)*)(?:")))) qr/q/ : (?-xism:(?:(?|(?:\")([^\\"]*(?:\.[^\\"]*)*)(?:\"))))


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found