in reply to Re^2: Regex curly bracket ambiguity
in thread Regex curly bracket ambiguity

$1 will give you the whole match. (?:) is a non-capturing grouping, so it does not affect $1, etc. If you used regular parens around $match, it would be returned in $2.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^4: Regex curly bracket ambiguity
by ysth (Canon) on Jun 21, 2007 at 18:23 UTC
    If you used regular parens around $match, it would be returned in $2.
    That is, the last repetition would be returned in $2:
    $ perl -w $match = "ab+"; $string = "fooababbabbbar"; $string =~ /(($match){3})/ && print "\$1: $1 \$2: $2\n"; __END__ $1: ababbabbb $2: abbb