|Pathologically Eclectic Rubbish Lister|
Regex only the longes Value , and possible speedup Problemby ultibuzz (Monk)
|on Nov 14, 2006 at 08:47 UTC||Need Help??|
ultibuzz has asked for the
wisdom of the Perl Monks concerning the following question:
i have the following Situation: a String of Numbers is given, an Array for matching several Numbers is given, i need to cut the matching Number and then print both the mathing Number and the rest with a ; between.
it shoud match from the beginning and it shoud match the longes possibility
Example: this number is given 012345666666 , these matchings are given 012345 and 0123456 , then 0123456 shoud be returnt not 012345
the array itself is 5025 elements big and i'm searching for faster ways then to join the array and doing a regex on each element.
also i can't find a way that the regex deliver back the longest matching possibility, for this reason i sortet the array so that the longest numbers comes first
my $filterregex = join('|',@Numbers)
i'am using the Regex vars matching and rest to get everything i need, but the regex is still not working correctly and it's not that fast.
Summary: regex needed that matches from the beginning and delivers just the longes matching value, a possible faster way woud be great