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

Thank you that was incredibly helpful.

so now that I have regular brackets around (?:$match); what 
do I do if I want to capture the whole thing?

eg with:
m/((?:$match){$repeat})/

will $1 give me everything or just $match back?

Replies are listed 'Best First'.
Re^3: Regex curly bracket ambiguity
by Roy Johnson (Monsignor) on Jun 21, 2007 at 18:11 UTC
    $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.
      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