T
Thomas F. O'Connell
I've been looking through the negative lookbehind posts and haven't
yet found a definitive answer to the question I'm about to ask:
Does negative lookbehind have lower precedence than even a non-greedy
wildcard (*) in the Perl regular expression engine?
The reason I ask is the following scenario:
I am try to match a pattern B as long as it is not preceded by a
pattern A in a given string, regardless of what occurs between B and
A.
To me, this seems a natural use of negative lookbehind. But when I try
the following expression:
/(?!<A).*B/
it does not work as I expect it to. I've tried both greedy and
non-greedy wildcards, and the only thing I can think is that the
wildcard takes precedence in matching up to B because of the rules of
matching in the engine. Is that correct?
Is there a way to solve this problem?
I've got Perl 5.8.0 for Linux.
Thanks!
-tfo
yet found a definitive answer to the question I'm about to ask:
Does negative lookbehind have lower precedence than even a non-greedy
wildcard (*) in the Perl regular expression engine?
The reason I ask is the following scenario:
I am try to match a pattern B as long as it is not preceded by a
pattern A in a given string, regardless of what occurs between B and
A.
To me, this seems a natural use of negative lookbehind. But when I try
the following expression:
/(?!<A).*B/
it does not work as I expect it to. I've tried both greedy and
non-greedy wildcards, and the only thing I can think is that the
wildcard takes precedence in matching up to B because of the rules of
matching in the engine. Is that correct?
Is there a way to solve this problem?
I've got Perl 5.8.0 for Linux.
Thanks!
-tfo