From: Leo <sdl.web@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Negate a regexp
Date: Mon, 19 Apr 2010 18:32:32 +0100 [thread overview]
Message-ID: <xbai7ho31h73.fsf@cam.ac.uk> (raw)
In-Reply-To: 8282B0BC46B0423AA171693F27FF1D22@us.oracle.com
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:
http://permalink.gmane.org/gmane.emacs.devel/123749.
Cheers,
Leo
next prev parent reply other threads:[~2010-04-19 17:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-19 14:57 Negate a regexp Leo
2010-04-19 15:51 ` Drew Adams
2010-04-19 17:32 ` Leo [this message]
2010-04-19 17:54 ` Thierry Volpiatto
2010-04-19 18:35 ` Leo
2010-04-19 21:41 ` Thierry Volpiatto
2010-04-20 13:44 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xbai7ho31h73.fsf@cam.ac.uk \
--to=sdl.web@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.