my $n = whatever... my $i=0; while ( ($string =~ /PATTERN/g) && ($i < $n ) ) { $i++; } my $NthMatch = $1;