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

Re: regex compilation

by Corion (Patriarch)
on Feb 12, 2019 at 17:37 UTC ( #1229824=note: print w/replies, xml ) Need Help??


in reply to regex compilation

Have you printed the two values you get? They are different because qq treats the backslash differently from what qr does.

Replies are listed 'Best First'.
Re^2: regex compilation
by morgon (Priest) on Feb 12, 2019 at 17:43 UTC
    The output is above in the end block.

    What I need is string that behaves just as the compiled regex as I want to feed that into a perl5-compatible regex-engine for go.

      Have you printed the two values you get?
      The output is above in the end block.

      I'm pretty sure that by "the two values", Corion meant $regex1 and $regex2.

      By the way, the only quoting construct that doesn't interpolate at all is here docs with a single-quoted delimiter:

      chomp( my $regex2 = <<'ENDREGEX' ); (?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\"))) ENDREGEX print $regex2, "\n"; my ($match2) = q|"hubba \"bubba\""| =~ /$regex2/; print $match2, "\n"; __END__ (?:(?|(?:\")([^\\\"]*(?:\\.[^\\\"]*)*)(?:\"))) hubba \"bubba\"
      ... string that behaves just as the compiled regex ...

      That's what  qr// is for; see perlop. The  Regexp object returned by qr// is almost a string; it interpolates as a string in  m// s/// qr// expressions or when print-ed or string interpolated. It is not, however, the same as what is produced by the  qq// q// operators.


      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://1229824]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2023-06-09 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (35 votes). Check out past polls.

    Notices?