my $str = 'one a two a three a four'; my $char = 'a'; my $n = 2; $str =~ /(?:.*?$char){$n}/g; print "Pos of '$char' #$n in '$str' is ", pos($str), "\n";
In reply to Re: The nth occurrence of a character
by Roy Johnson
in thread The nth occurrence of a character
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |