Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Regex only the longes Value , and possible speedup Problem

by Anonymous Monk
on Nov 14, 2006 at 09:46 UTC ( [id://583932]=note: print w/replies, xml ) Need Help??


in reply to Regex only the longes Value , and possible speedup Problem

Why bother with a regex? I'd use substr(), and do something like:
my $search_str = "..."; my @numbers = (...); foreach my $n (sort {length($b) <=> length($a)} grep {length($_) <= length($search_str)} @numbers) { if ($n eq substr($search_str,0,length $n)) { print "$n matched!\n"; exit; } } print "No match!\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583932]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2024-04-18 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found