in reply to Re^3: Compiled regular expression using qr
in thread Compiled regular expression using qr

My bad, I reinitialized the variable as part of debugging, no wonder it would not match.

Thanks for clarifying on its use. That said, the stringify version has ?^ in front, I know that ? means 0 or more of the chars preceding it, but what does ?^ mean?

  • Comment on Re^4: Compiled regular expression using qr

Replies are listed 'Best First'.
Re^5: Compiled regular expression using qr
by AnomalousMonk (Archbishop) on Oct 15, 2014 at 23:54 UTC

    A stringized regex object is wrapped in a non-capturing grouping that preserves the regex modifiers in effect when the regex was compiled. This allows a regex object to be unaffected by the modifiers in effect in any enclosing regex 'scope' during interpolation within another regex or regex object. Consider:

    c:\@Work\Perl>perl -wMstrict -le "my $rx = qr/(?^xms:^data_123$)/; print $rx; ;; my $ry = qr/^data_123$/xms; print $ry; ;; my $rz = qr{ T $rx U $ry V }xms; print $rz; " (?^:(?^xms:^data_123$)) (?^msx:^data_123$) (?^msx: T (?^:(?^xms:^data_123$)) U (?^msx:^data_123$) V )
    See also the discussion of  "(?^aluimsx:pattern)" in the Extended Patterns section of perlre.

Re^5: Compiled regular expression using qr
by ikegami (Patriarch) on Oct 15, 2014 at 23:05 UTC
    ?^ is garbage. (?^i:...), on the other hand, means that the pattern within should be matched case-insensitively as you requested.