in reply to Problem with CGI script not working (regex at fault)

Your problem description makes me suspicious that your regex is taking too many resources in the case you site.

You see, you neglected one of the possible outcomes that becomes much more likely when you use such a horrid regex. The possible outcomes of using a regex are:

I don't understand why you refuse to use a module designed to deal with this type of problem. But at least follow the advice given in the node you reference! I suspect that many of your uses of .*? can be replaced with [^>]* or [^<]*, for example. And something like [^>]*> never has to backtrack.

Each time you use .* or .*?, you give the regex one more place to try backtracking. One such place may mean the regex backtracks over the whole string once. Two such places can end up with the first place backtracking over the whole string and at each point in the string, the second one could backtrack over one side of the string.

So, on a string of length L with B spots in the regex that could require backtracking, you have a potential for run-time propotial to L**B. Such a regex could run very fast when it finds a match but take the full O(L**B) in cases when there is no match to be found.

        - tye (but my friends call me "Tye")