Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re(3): regexp hang?

by Arien (Pilgrim)
on Aug 22, 2002 at 06:02 UTC ( [id://191940]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: regexp hang?
in thread regexp hang?

tye has already told you why you could see slowness caused by backtracking. Also, I would write "seperate $string in two parts: the first 200 words ($intro) and the rest ($rest)" like this:

($rest = $string) =~ s/\A((?:\w+\W+){200})//s and $intro = $1;

(Assuming your string starts with a word character and you don't mind the extra non-word character(s) after the 200th word.)

— Arien

Edit: If you don't care about changing the value of $string you could obviously leave out the copy to $rest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2025-02-09 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.