in reply to RegEx - match pattern not followed by literal

Do you hear that, Mr. Anderson? That's the sound of premature optimization . . .

The overhead in it being two regexen is so likely trivial as to not be worth the effort. Not to mention you could probably get more of a boost by rearranging the cases so the trivial presence of /,v$/ is checked first before bothering to go on to the user's regex.

Replies are listed 'Best First'.
Re^2: RegEx - match pattern not followed by literal
by Melly (Chaplain) on Oct 12, 2006 at 15:45 UTC

    Well, it wasn't really a question about optimisation (in terms of speed) - more about 'neatness'.

    That said, good point about testing for ,v prior to the user's regex.

    Hey! Did you down-vote me? Wah! This means war...

    Tom Melly, tom@tomandlu.co.uk

      I downvote everyone. Even myself.

      Well, it wasn't really a question about optimisation (in terms of speed) - more about 'neatness'.

      Neatness is in the eye of the beholder. General rule is: if it fits naturally in two separate matches then chances are that indeed it may be done in one, but at the expense of neatness, and vice versa. I say so because it happens all the time to read about people who "want to do it in just one match" since they think it's neater. Most times it plainly won't be.