$ perl -w $match = "ab+"; $string = "fooababbabbbar"; $string =~ /(($match){3})/ && print "\$1: $1 \$2: $2\n"; __END__ $1: ababbabbb $2: abbb