in reply to Re: Regex optimization: Can (?> ) and minimal match help here?
in thread Regex optimization: Can (?> ) and minimal match help here?

I think that ($attribute*?) really should be ($attribute*), because if you have multiple attributes, the RE engine first try to match zero, then one, then two etc., instead of matching them all in the first place.

Yes, it would match them all, but that would be a bug. He doesn't want it to match the type= attribute since he's replacing it.

Replies are listed 'Best First'.
Re^3: Regex optimization: Can (?> ) and minimal match help here?
by moritz (Cardinal) on Jun 18, 2008 at 16:15 UTC
    You're right. One possible optimization is to change the regex for attributes not to match type (with negative lookahead), and then use the * star. I don't know if that's actually faster, but I'm sure the OP will benchmark it if speed is really important.