help-gnu-emacs
[Top][All Lists]
Advanced

[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:11:27 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Tassilo Horn <tassilo@member.fsf.org> 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)) - that's why I (still :-)) think these features
should be implemented in Emacs as well.

Tim




reply via email to

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