in reply to Re: problem with regex
in thread problem with regex
There should be a "g" at the end of those lines:
otherwise the regexp matches only once instead of searching for all abc<some_number>.my @find = $line[$i] =~ /(?:\A|\t)(abc\d+)(?=\t|\z)/g;
And if you happen to need to count each of the abc<some_number> separately you can either process the @find:
my @find = $line[$i] =~ /(?:\A|\t)(abc\d+)(?=\t|\z)/ my %count; $count{$_}++ for @find;
or skip building the array
while ($line[i] =~ /(?:\A|\t)(abc\d+)(?=\t|\z)/g) { $count{$1}++; }
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: problem with regex
by davido (Cardinal) on Jul 22, 2012 at 08:30 UTC |