[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regexp and strings you don't want
From: |
Oliver Scholz |
Subject: |
Re: regexp and strings you don't want |
Date: |
Fri, 29 Aug 2003 18:14:24 +0200 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt) |
kai.grossjohann@gmx.net (Kai Großjohann) writes:
> chaz2@thedoghousemail.com (Chaz) writes:
>
>> For example, how can I search for a paragraph beginning with "The"
>> that does NOT include the word "top"?
>
> It is possible to build a regexp that does this (disregarding the
> paragraph problem at the moment), but it is not pretty.
>
> Some regexp implementations have the feature you're looking for to
> make it convenient, but the Emacs implementation doesn't.
>
> Let me rephrase this in terms of lines instead of paragraphs.
>
> The idea is this: search for a line that begins with The and then
> does not have top after it, as follows: after The, we allow any
> characters that aren't t. We also allow a t followed by something
> that's not o, and also a to that's followed by something that's not
> p. And so on:
>
> "^The\\([^t]*\\($\\|t$\\|t[^o]\\|to$\\|to[^p]\\)\\)*$"
Hmm. This is not really human readable. Would it be hard and/or bad
to extend `rx' so that it allows for (not STRING)? A là:
(looking-at (rx (and line-start
"The "
(not "top"))))
Whereas `(not "top")' would compile to a normal regexp in the way you
described it. WDYT?
Oliver
--
12 Fructidor an 211 de la Révolution
Liberté, Egalité, Fraternité!
- regexp and strings you don't want, Chaz, 2003/08/25
- Re: regexp and strings you don't want, Barry Margolin, 2003/08/25
- Re: regexp and strings you don't want, Eric Pement, 2003/08/26
- Re: regexp and strings you don't want, Kai Großjohann, 2003/08/27
- Re: regexp and strings you don't want,
Oliver Scholz <=
- Re: regexp and strings you don't want, Oliver Scholz, 2003/08/29
- Re: regexp and strings you don't want, Oliver Scholz, 2003/08/29
- Re: regexp and strings you don't want, Kai Großjohann, 2003/08/29
- Re: regexp and strings you don't want, Oliver Scholz, 2003/08/29
- Re: regexp and strings you don't want, Ilya Zakharevich, 2003/08/30