WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: pattern and infinite loop

Re: pattern and infinite loop

by no spam-11 :: Rate this Message:

| View in Thread

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

 « Return to Thread: pattern and infinite loop