From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Friedrich Dominicus Newsgroups: gmane.emacs.help Subject: Re: Newbie regexp question Date: 30 Oct 2002 18:42:36 +0100 Organization: Q Software Solutions GmbH Sender: help-gnu-emacs-admin@gnu.org Message-ID: <873cqnq0vn.fsf@fbigm.here> References: <3DBFF5F8.B78A64CA@enea.se> <8765vkkkko.fsf@fbigm.here> <3DC00D40.B76302FD@enea.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1036002748 7107 80.91.224.249 (30 Oct 2002 18:32:28 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 30 Oct 2002 18:32:28 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 186xdj-0001qU-00 for ; Wed, 30 Oct 2002 19:32:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 186xef-0002VR-00; Wed, 30 Oct 2002 13:33:25 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-X-Trace: news.t-online.com 1035999718 06 12212 a7s9b0+TS-Yq8V 021030 17:41:58 Original-X-Complaints-To: abuse@t-online.com X-Sender: 320004655587-0001@t-dialin.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) Original-Xref: shelby.stanford.edu gnu.emacs.help:106576 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3127 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3127 Michael Slass writes: > > I think a lisp program would do better at this: > > VERY LIGHTLY TESTED. MAKE BACKUPS BEFORE EXPERIMENTING WITH THIS! > > (defun paulc-purge-html-test-sections (buffer) > "Delete all occurances of text between and , inclusive." > (interactive "bPurge html test sections in buffer: ") > (save-excursion > (save-restriction > (goto-char (point-min)) > (while (re-search-forward "" nil t) > (let ((beg (match-beginning 0)) > (end (progn (re-search-forward "" nil t) > (match-end 0)))) > (if end > (kill-region beg end) > (error "Unmatched \"\" sequence at position %d" beg))))))) Well this code is better in some areas, but Mike you missed a big opportunity ;-) To let the user choose what the tags are and as mentioned before regular expressions are overkill if you know your data. However a really nice solution anyway I think there is a problem with the end stuff. The info pages say: Search forward from point for regular expression REGEXP. Set point to the end of the occurrence found, and return point. That means you will return the End tags too, if I got that right, which is not sure I'm a tired and had an unpleasant quarrel with someone I really appriciate. So good night Friedrich