Re: pattern and infinite loop

no spam <[email protected]> Mon, 19 Jan 2009 21:39:11 -0500
Newsgroups gmane.comp.jakarta.oro.user
Message-ID <[email protected]>
--000e0cd6a8acb6f27e0460e0f162
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

I'm using contains.  Strange .. not sure what's going on.

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

Ah yes I figured that was the issue after I saw your pattern.   The bits I
don't understand though is how [^<]* is working.  What exactly does that
part of the pattern mean?

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

--000e0cd6a8acb6f27e0460e0f162--