From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: regexp with match over multiple lines Date: Thu, 05 May 2011 19:28:16 +0200 Message-ID: <4DC2DE30.3020502@easy-emacs.de> References: <31548643.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304616517 32575 80.91.229.12 (5 May 2011 17:28:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 5 May 2011 17:28:37 +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 19:28:33 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 1QI2Lp-0000g5-Cm for geh-help-gnu-emacs@m.gmane.org; Thu, 05 May 2011 19:28:33 +0200 Original-Received: from localhost ([::1]:56817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI2Lo-0004Hy-Lr for geh-help-gnu-emacs@m.gmane.org; Thu, 05 May 2011 13:28:32 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI2Lj-0004HX-AF for help-gnu-emacs@gnu.org; Thu, 05 May 2011 13:28:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QI2Li-00011m-8G for help-gnu-emacs@gnu.org; Thu, 05 May 2011 13:28:27 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.9]:57584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QI2Lh-00011S-Oe for help-gnu-emacs@gnu.org; Thu, 05 May 2011 13:28:26 -0400 Original-Received: from [192.168.178.27] (brln-4d0c3e6f.pool.mediaWays.net [77.12.62.111]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MMrpj-1QPQjY0CvX-008WIA; Thu, 05 May 2011 19:28:23 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 In-Reply-To: <31548643.post@talk.nabble.com> X-Provags-ID: V02:K0:RUznWIOPeopNF2ySmvJGi2Nv4RbZZTMvx7b/x7jurVc hIK9HFJNw3okUQX3teqEaEhmW6T3KtL9BM3WuTZcpX2X7vKfCA C8pI2ZSBj3Oc9FaB+NvjcR5VC9ESb9LzaNtONOdq/3gCKt0NPi JunxkB4mR9ypAADtLQU8lj5IhtV8rZUo6I/dg/l/sq6MnFhWHe IqLjvk9SG70zNvim4ldwc1WTmKUvbT1yyv4GZmZVCw= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.17.9 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:80925 Archived-At: 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 Hi, when dealing with expressions characterized by a start- and end string, quite often a little function is convenient: Below a simplified example: (setq startstring "abc") (setq endstring "def") (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)))))) abcABCDEFdefAAAAAAAAAA -> AAAAAAAAAA