Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
We don't bite newbies here... much
 
PerlMonks  

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

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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;

Replies are listed 'Best First'.
Re^2: Regex only the longes Value , and possible speedup Problem
by ultibuzz (Monk) on Nov 14, 2006 at 05: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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://583934]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.