"abbbbbc" =~ /(b)*?(b*?)c/; print "\$1: $1\n" if defined $1; print "\$2: $2\n" if defined $2; Prints: $2: bbbbb