in reply to Purpose of the "caret" character in "qr" regex output
In (?<modifiers>:...) <modifiers> (if present) is some mixture of the 'imopsx' modifiers usually found at the end of a regex. '^' is a modifier in this context that means "use the system default modifiers 'd-imsx'". I'm guessing qr does this to get predictable behavior when $regex is embedded in a larger regex.
Consider:
use strict; use warnings; my $text = 'Abcd'; my $match = 'abcd'; my $regex = qr/$match/; print "No match: '$text', '$match'\n" if $text !~ /$regex/i; print "/i match: '$text', '$match'\n" if $text =~ /$match/i;
Prints:
No match: 'Abcd', 'abcd' /i match: 'Abcd', 'abcd'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Purpose of the "caret" character in "qr" regex output
by roho (Bishop) on Jul 31, 2025 at 04:34 UTC |