in reply to Re^4: Regex infinite loop?
in thread Regex infinite loop?
Yikes ! This gave me an opportunity to learn a bit about debuggering regex.
The pragma use re 'debug' will tell you more than you ever thought you might have wanted to know about the regex being processed.
The problem I found was that the 'colts' html contains:
<td class="qty" style="width: 7%;">where your regex was looking for:
<td class="qty">Because the regex is littered with .*?, there is lots of scope for backtracking. As far as I can see:
I doubt that this is an infinite loop. But I haven't the patience to establish one way or the other.
Not sure what to suggest here... Where possible I would replace .*? by, for example, [^<]*? -- which limits the scope for backtracking. There is other regex magic to limit backtracking, but I'm not familiar with it.
However, the big problem I see is that you can never be sure whether your regex has failed because there is no more data of interest, or because it's not recognising a small variation in format. Do you have a drawing board ?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Regex infinite loop?
by Ninth Prince (Acolyte) on Oct 17, 2008 at 14:32 UTC |