XP is just a number | |
PerlMonks |
Re: 'g' flag w/'qr'by kcott (Archbishop) |
on May 29, 2016 at 09:53 UTC ( [id://1164437]=note: print w/replies, xml ) | Need Help?? |
G'day perl-diddler, "So how can I attach the "/g" modifier to my "qr" regex ... ?"
The 'g' modifier is used by m// and s/// to direct how a regex is to be used (single match, global substitution, etc.); it does not affect the regex itself. qr// has no 'g' modifier. Here's links to all three (note the modifier lists): The 'g' modifier is not part of qr//'s syntax and, if used, syntax errors are raised (as expected).
You also can't do it with the re pragma's '/flags' mode:
See also: On a side note — related to what you're doing but not the current problem at hand — are you familiar with the '(?<flags>:<pattern>)' regex construct described in perlre: Extended Patterns: (?adluimnsx-imnsx:pattern)? This construct, and qr//'s interpolating, allows you to write something like this:
Now you control the available flags and don't have to worry about qr//'s modifiers. By the way, you can't add a 'g' modifier using this method either. :-)
— Ken
In Section
Seekers of Perl Wisdom
|
|