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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.