From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: AngusC Newsgroups: gmane.emacs.help Subject: Re: regexp with match over multiple lines Date: Thu, 5 May 2011 11:17:07 -0700 (PDT) Message-ID: <31552827.post@talk.nabble.com> References: <31548643.post@talk.nabble.com> <4DC2DE30.3020502@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1304619442 17741 80.91.229.12 (5 May 2011 18:17:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 May 2011 18:17:22 +0000 (UTC) To: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 05 20:17:18 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QI370-0002mi-2F for geh-help-gnu-emacs@m.gmane.org; Thu, 05 May 2011 20:17:18 +0200 Original-Received: from localhost ([::1]:48651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI36z-0003sa-J2 for geh-help-gnu-emacs@m.gmane.org; Thu, 05 May 2011 14:17:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:54842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI36q-0003sG-S5 for Help-gnu-emacs@gnu.org; Thu, 05 May 2011 14:17:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QI36p-0002Og-SZ for Help-gnu-emacs@gnu.org; Thu, 05 May 2011 14:17:08 -0400 Original-Received: from sam.nabble.com ([216.139.236.26]:51492) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI36p-0002Oa-P8 for Help-gnu-emacs@gnu.org; Thu, 05 May 2011 14:17:07 -0400 Original-Received: from isper.nabble.com ([192.168.236.156]) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1QI36p-00085c-8l for Help-gnu-emacs@gnu.org; Thu, 05 May 2011 11:17:07 -0700 In-Reply-To: <4DC2DE30.3020502@easy-emacs.de> X-Nabble-From: anguscomber@gmail.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 216.139.236.26 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:80927 Archived-At: Andreas R=C3=B6hler wrote: >=20 > Am 05.05.2011 11:05, schrieb AngusC: >> >> I want to remove all instances of data in a file. My >> regexp works if the start and end tag is on the same line. But not if >> the >> end tag is not on this same line. Is it possible to apply regex across >> multiple lines. >> >> My regex is:<\!\[CDATA\[.*\]\]> and that works if all on one line. >> >> What can I do? Is this where lisp required? >> >> Angus >=20 > Hi, >=20 > when dealing with expressions characterized by a start- and end > string, quite often a little function is convenient: >=20 > Below a simplified example: >=20 > (setq startstring "abc") > (setq endstring "def") >=20 > (defun my-start-end-delete () > " " > (interactive "*") > (let (beg) > (while (search-forward startstring nil (quote move) 1) > (setq beg (match-beginning 0)) > (when (search-forward endstring nil (quote move) 1) > (delete-region beg (match-end 0)))))) >=20 > abcABCDEFdefAAAAAAAAAA -> AAAAAAAAAA >=20 >=20 I am thinking I probably need to learn lisp to have real power. More regex would probably help. --=20 View this message in context: http://old.nabble.com/regexp-with-match-over-= multiple-lines-tp31548643p31552827.html Sent from the Emacs - Help mailing list archive at Nabble.com.