in reply to regex picking out a particular string
my $semiColon=2; my ($substring) = $string =~ /(?:;.*?){$semiColon}(.*?);/;
If you want to find the nth piece of a m-piece string where n << m it can make sense to use the match approach.
Note: $substring will be undef is $string contained fewer then $semiColon+1 semicolons.
Update: Correction, I meant where n and m are both large. If n is small then simply use the LIMIT arg of split!
|
|---|