Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by reneeb (Chaplain)
on Nov 14, 2006 at 09:50 UTC ( #583934=note: print w/ replies, xml ) Need Help??


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

You could use this:

#!/usr/bin/perl use strict; use warnings; my @numbers = ('012345','0123456'); @numbers = sort{length $b <=> length $a}@numbers; my $regex = join('|',@numbers); my $string = '0123456778945'; $string =~ s!^($regex)(.*)!$1;$2!; print $string;


Comment on Re: Regex only the longes Value , and possible speedup Problem
Download Code
Re^2: Regex only the longes Value , and possible speedup Problem
by ultibuzz (Monk) on Nov 14, 2006 at 10:19 UTC
    hi reneeb,
    i just testet your code a bit changed with a live case and it looks like it's working perfectly, and it was fast

    kd ultibuzz

    Update: time for a 500000 file with additional loops for stuff is 2.632 seconds, thats fast ;)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2015-07-05 06:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls