* regex nirvana - near miss
@ 2014-06-26 15:18 Buchs, Kevin J.
2014-06-26 15:36 ` Yuri Khan
2014-06-26 16:35 ` Drew Adams
0 siblings, 2 replies; 4+ messages in thread
From: Buchs, Kevin J. @ 2014-06-26 15:18 UTC (permalink / raw)
To: help-gnu-emacs
Often I wish to match a string not followed by another string, e.g.
"abc" without "def" following. I had a glimpse of nirvana today when I
thought of trying this RE: abc\(def\)\{0\}, but alas it was not to be
had as it gets optimized and just matches "abc". It is tedious to use:
abc\([^d]\|d[^e]\|de[^f]\), especially when the second string gets longer.
--
Kevin Buchs Research Computer Services Phone: 507-538-5459
Mayo Clinic 200 1st. St SW Rochester, MN 55905
http://mayoclinic.org http://facebook.com/MayoClinic http://youtube.com/MayoClinic http://twitter.com/MayoClinic
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: regex nirvana - near miss
2014-06-26 15:18 regex nirvana - near miss Buchs, Kevin J.
@ 2014-06-26 15:36 ` Yuri Khan
2014-06-26 16:35 ` Drew Adams
1 sibling, 0 replies; 4+ messages in thread
From: Yuri Khan @ 2014-06-26 15:36 UTC (permalink / raw)
To: Buchs, Kevin J.; +Cc: help-gnu-emacs@gnu.org
On Thu, Jun 26, 2014 at 10:18 PM, Buchs, Kevin J. <buchs.kevin@mayo.edu> wrote:
> Often I wish to match a string not followed by another string, e.g. "abc"
> without "def" following. I had a glimpse of nirvana today when I thought of
> trying this RE: abc\(def\)\{0\}, but alas it was not to be had as it gets
> optimized and just matches "abc". It is tedious to use:
> abc\([^d]\|d[^e]\|de[^f]\), especially when the second string gets longer.
What you are looking for is called a negative lookahead assertion, and
no, Emacs currently does not support them.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: regex nirvana - near miss
2014-06-26 15:18 regex nirvana - near miss Buchs, Kevin J.
2014-06-26 15:36 ` Yuri Khan
@ 2014-06-26 16:35 ` Drew Adams
1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2014-06-26 16:35 UTC (permalink / raw)
To: Buchs, Kevin J., help-gnu-emacs
> Often I wish to match a string not followed by another string, e.g.
> "abc" without "def" following.
Typically, what you want to do for this in Emacs Lisp is to combine
the use of a regexp for positive matching with other code that takes
care of the non-matching (negation) need.
For example, you want to find a match for `abc' that does not also
match `def' at the `abc' match end. Search for `abc', and then
programmatically exclude search hits where `def' follows `abc'.
Or if you want to complement a set of regexp matches, compute it
and then subtract it from the original search space.
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.4351.1403795929.1147.help-gnu-emacs@gnu.org>]
end of thread, other threads:[~2014-06-26 16:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 15:18 regex nirvana - near miss Buchs, Kevin J.
2014-06-26 15:36 ` Yuri Khan
2014-06-26 16:35 ` Drew Adams
[not found] <mailman.4351.1403795929.1147.help-gnu-emacs@gnu.org>
2014-06-26 15:38 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).