From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: regexp with match over multiple lines
Date: Fri, 06 May 2011 10:27:29 +0200 [thread overview]
Message-ID: <4DC3B0F1.4080203@easy-emacs.de> (raw)
In-Reply-To: <31552827.post@talk.nabble.com>
Am 05.05.2011 20:17, schrieb AngusC:
>
>
> 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.
>
For me pleasure started when having some Emacs Lisp.
Before it was promising - afterward great :)
Cheers
prev parent reply other threads:[~2011-05-06 8:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 9:05 regexp with match over multiple lines AngusC
2011-05-05 10:04 ` Peter Dyballa
2011-05-05 16:58 ` AngusC
2011-05-05 17:02 ` Deniz Dogan
2011-05-05 18:15 ` AngusC
2011-05-05 20:05 ` PJ Weisberg
2011-05-05 22:10 ` Peter Dyballa
2011-05-06 11:10 ` AngusC
2011-05-06 12:35 ` Peter Dyballa
2011-05-06 11:20 ` AngusC
2011-05-06 13:52 ` Peter Dyballa
2011-05-05 13:08 ` ken
2011-05-05 17:28 ` Andreas Röhler
2011-05-05 18:17 ` AngusC
2011-05-06 8:27 ` Andreas Röhler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DC3B0F1.4080203@easy-emacs.de \
--to=andreas.roehler@easy-emacs.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).