From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: kai.grossjohann@gmx.net (=?iso-8859-1?q?Kai_Gro=DFjohann?=) Newsgroups: gmane.emacs.help Subject: Re: regexp and strings you don't want Date: Wed, 27 Aug 2003 22:26:23 +0200 Organization: University of Duisburg, Germany Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <844r02luds.fsf@slowfox.is.informatik.uni-duisburg.de> References: <6c185cf3.0308251145.6af55ffc@posting.google.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1062017090 22594 80.91.224.253 (27 Aug 2003 20:44:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2003 20:44:50 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 27 22:44:48 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19s79s-0001uA-00 for ; Wed, 27 Aug 2003 22:44:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 19s6zn-0004yp-FH for geh-help-gnu-emacs@m.gmane.org; Wed, 27 Aug 2003 16:34:23 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!in.100proofnews.com!in.100proofnews.com!fu-berlin.de!uni-berlin.de!pd9e1e82c.dip.t-dialin.NET!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-NNTP-Posting-Host: pd9e1e82c.dip.t-dialin.net (217.225.232.44) Original-X-Trace: news.uni-berlin.de 1062015984 10611986 217.225.232.44 (16 [73968]) Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:YXC9cEZr0Tuob0FAFiR4WBa2Uy4= Original-Xref: shelby.stanford.edu gnu.emacs.help:116182 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12102 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12102 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]\\)\\)*$" The above regexp is in Lisp syntax, with doubled backslashes. Note that I treat the newline that might follow a t, or to, specially. Do you see the idea? I hope I haven't made a mistake, but if you understand the idea, you'll see what to do. -- Two cafe au lait please, but without milk.