in reply to Re: Tell or determine whichever Perl regex group fails
in thread Tell or determine whichever Perl regex group fails
Anchoring the match would change that.
'okoK'=~ /^(o|k)(k|i)(O|K)(K)/
You can alter this pattern to give the the desired information.
'okoK'=~ / ^ (?: (o|k) (?: (k|i) (?: (O|K) (?: (K) )? )? )? )? /x; my $n = length($&); # -or- use List::Util qw( first ); my $n = first { defined($-[$_]) } 1..4;
|
|---|