Are you trying to determine whether a regex had capture groups or not?Thanks - that's very interesting (@LAST_MATCH_START).
Through some code I am currently working on I discovered a potential problem here, there is a subtle but very important distinction between @- and @+, from the former:
One can use $#- to find the last matched subgroup in the last successful match. Contrast with $#+, the number of subgroups in the [last successful] regular expression.
$ perl -MData::Dump -e '"ya"=~/(x)?/; dd $#-, \@-, $#+, \@+' (0, [0], 1, [0, undef])
And updating my previous example:
"1" =~ /1/ or die; print $#-?"yes\n":"no\n"; # -> no "1" =~ /(1)?/ or die; print $#-?"yes\n":"no\n"; # -> yes "1" =~ /(2)?/ or die; print $#-?"yes\n":"no\n"; # -> no !! "1" =~ /(2)?/ or die; print $#+?"yes\n":"no\n"; # -> yes
In reply to Re^5: How can I test for the representation of an integer?
by haukex
in thread How can I test for the representation of an integer?
by sm@sh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |