![]() |
|
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?? |
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.
In Section
Seekers of Perl Wisdom
|
|