[Top][All Lists]

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

Re: Negate a regexp

From: Leo
Subject: Re: Negate a regexp
Date: Mon, 19 Apr 2010 18:32:32 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On 2010-04-19 16:51 +0100, Drew Adams wrote:
>> How to negate a regexp? For example this one: \(?:\sw\|\s_\|\s\\).
> You cannot express a complement using (real) regexps. Regular expressions are
> just not that expressive (powerful).
> However, Emacs Lisp is that powerful; its use of regexps is not limited to 
> real
> regular expressions; and you can bathe your use of regexps in a more powerful
> sauce.
> In Emacs Lisp, you can in some cases use complementary syntax: \W as 
> complement
> of \w, \S_ as complement of \s_, etc. And you can use ^ at the beginning of a
> [...] character set to complement that set (what the manual calls a
> "complemented character alternative"). See node `Syntax of Regexps' in the 
> Elisp
> manual.
> Another thing you can do is to use a regexp to determine a set of matches -
> those elements you do not want, and then, assuming you know the overall domain
> explicitly (extensively), subtract those matches to get the complement (those
> elements of the domain that do not match).

I need to provide a regexp to an abbrev table so that the match in group
1 (which is the abbrev name) can contain word symbol or \. The match is
done through (looking-back ...) with the GREEDY arg omitted. For example
in a buffer with text \coor-!-, where -!- indicates point, (looking-back
REGEXP) (match-string 1) should return \coor. Any idea how to construct
such a REGEXP?

I am not entirely sure the way the :regexp to abbrev table should be
provided is well thought-out. See my question to emacs-devel:



reply via email to

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