Why/how is an additional variable needed in matching repeated arbitary character with capture groups?
问题 I'm matching a sequence of a repeating arbitrary character, with a minimum length, using a perl6 regex. After reading through https://docs.perl6.org/language/regexes#Capture_numbers and tweaking the example given, I've come up with this code using an 'external variable': #uses an additional variable $c perl6 -e '$_="bbaaaaawer"; /((.){} :my $c=$0; ($c)**2..*)/ && print $0'; #Output: aaaaa To aid in illustrating my question only, a similar regex in perl5: #No additional variable needed perl -e