On Tue, Jun 01, 2004 at 02:11:56PM -0400, kynn@xxxxxxxxx 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.
Ronald
|