in reply to How do I find the Nth occurrence of a pattern?

Haven't tested this, but liked the idea.... :)
my $n = whatever... my $i=0; while ( ($string =~ /PATTERN/g) && ($i < $n ) ) { $i++; } my $NthMatch = $1;

Replies are listed 'Best First'.
d'oh
by cLive ;-) (Prior) on Mar 30, 2001 at 10:55 UTC