Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to print the original qr regex to the stdout?

by Anonymous Monk
on Feb 28, 2022 at 10:15 UTC ( [id://11141700]=note: print w/replies, xml ) Need Help??


in reply to How to print the qr regex to the stdout?

It adds the ?^: at the start. What is the proper way to get rid of it?

Try Data::Dump pp to serialize regex or something from re or B to get original qr

maybe use https://perldoc.perl.org/re#regexp_pattern($ref)

my ($pat, $mods) = regexp_pattern($ref); my $parentless = ( $pat =~ m/[^:]+:(.*?)\)$/s )[0];

Replies are listed 'Best First'.
Re^2: How to print the original qr regex to the stdout?
by ovedpo15 (Pilgrim) on Feb 28, 2022 at 10:38 UTC
    Thank you very much!
    One question - why the second line is needed? It looks like $pat does what I need.
      My cell phone doesnt have perl, the doc example implied the (^:) being returned

Log In?
Username:
Password:

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

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

    No recent polls found