help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regexp with match over multiple lines


From: AngusC
Subject: Re: regexp with match over multiple lines
Date: Thu, 5 May 2011 11:17:07 -0700 (PDT)


Andreas Röhler wrote:
> 
> Am 05.05.2011 11:05, schrieb AngusC:
>>
>> I want to remove all instances of<![CDATA[ ... ]]>  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
> 
> 

I am thinking I probably need to learn lisp to have real power.  More regex
would probably help.

-- 
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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]