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.
|
|---|