[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does emacs regular expression support (?!expression)

From: Tim Landscheidt
Subject: Re: does emacs regular expression support (?!expression)
Date: Thu, 02 Feb 2012 22:17:04 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

I wrote:

>> [...]

>>>> matches "foo19" or "bar23", but doesn't capture foo or bar, so that
>>>> (match-string 1) is the number.

>>> In Perl, "(?!pattern)" is a zero-width negative look-ahead
>>> assertion.  Emacs does not support these AFAIK.

>> I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
>> "foo\\(?:[^b][^a][^r]\\)" in elisp.

> You have to account for possible end-of-buffer as well so
> usually it's "easier" to use two matches ('(while (and
> (search-forward-regexp "foo") (not (looking-at "bar"))))'
> (untested)) - [...]

Eh, yes, there is an "(untested)", but still the logic is
obviously plain wrong.  But you get the idea.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]