Re: pattern and infinite loop
"Daniel F. Savarese" <[email protected]> Mon, 19 Jan 2009 13:01:33 -0500
| Newsgroups | gmane.comp.jakarta.oro.user |
|---|---|
| Message-ID | <[email protected]> |
In message <[email protected]>, no sp am writes: >Yes that's correct. This pattern prevented the looping it just didn't match >for that particular page. I'll have to digest this pattern a bit more in my >head :o) Are you using contains() or match()? If you're using match(), then switch to contains() and it should work. Here's my sanity check for the pattern (to avoid having to write a Java test program): ~> wget -O - http://www.myspace.com/pain 2> /dev/null | perl -e '@txt = <STDIN>; $txt = join("", @txt); $txt =~ m#<span\s+class="nametext">[^<]*</span><br>[^<]*<font\s[^>]*><strong>([^<]+)</strong></font>#si; print "$1\n";' Metal / Industrial In any case, the key to prevent excessive backtracking is to make the pattern as specific as possible. The original pattern posed problems because of the leading .* as well as following .+ pattern elements which caused a lot of backtracking.