On Fri, Feb 15, 2002 at 07:27:03AM -0600, Tim Ayers wrote: > >>>>> "A" == Andrew Pimlott <[EMAIL PROTECTED]> writes: > A> On Fri, Feb 15, 2002 at 01:37:15AM -0500, Jeff 'japhy' Pinyan wrote: > >> Except that you are forced to find a 2-character match, which means you > >> end up skipping a POTENTIAL 3-character-or-more match. > > A> Due to the while loop, we will keep looking for longer matches. > A> Otherwise, your version would have a similar bug, finding earlier, > A> shorter matches. > > No offense, but did you try it without the comma? It doesn't work. If > you get a 2-character match, the regex engine gains a new starting > point for the 3-character match. Thus throwing away the 2 characters > that just matched. If they are part of the lcs, you just lost part of > your answer.
It does work, if you drop the comma *and* the /g modifier, so that it starts searching at the beginning of the string each time. Ronald