Date: Tue, 1 Jun 2004 14:21:16 -0400
   From: Ronald J Kimball <[EMAIL PROTECTED]>

   On Tue, Jun 01, 2004 at 02:11:56PM -0400, [EMAIL PROTECTED] wrote:

   >     13  '__pqr____xyz__pqr___abc___' =~ /(($re).*?)*(?!)/;

   > Of course, this is incomplete, but it is a start.  One thing that
   > puzzles me is that the (?!) is absolutely required on line 13.
   > Without it, @seen doesn't get initialized at all.  Why should this be?
   > I would have thought that the final '*' in the regexp would be enough
   > to get the regexp to continue attempting to match.

   /(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.

kj

Reply via email to