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