On Tue, Jun 01, 2004 at 05:22:01PM -0400, [EMAIL PROTECTED] wrote:
> 
>    /(anything)*/ can always match a zero length substring at the beginning of
>    the string, and as soon as the regex engine finds a match, it stops.  The
>    (?!) forces the regex engine to backtrack through all possible matches.
> 
> I can see how that would be the case if the modifier were *?, but with
> plain * I expect the engine to match greedily, and not stop at the
> first match.

Emphasis: *at the beginning of the string*.

Without the (?!), your regex matches zero occurences of $re at the
beginning of the string.

The regex engine always finds the longest, *leftmost* match.  (Where
"longest" really means "with the least backtracking".)

Ronald

Reply via email to