From: Gregory Benjamin <gregb@laserlab.com>
To: help-gnu-emacs@gnu.org
Subject: Help with regex including newline
Date: Wed, 28 Mar 2012 15:03:13 -0700 [thread overview]
Message-ID: <20120328220313.GA1859@dbn66.laserlab.com> (raw)
I've been struggling with this for more than an hour...
I'm using GNU Emacs 24.0.93.2
Given the following text in a buffer:
<!-- this is some garbage that I want to match and
strip out of the buffer. It may span many lines before
reaching the end. -->
I wish to use M-x replace-regexp to delete the entire pattern,
including the opening '<' and closing '>'.
Using M-x re-builder, I came up with the following regexp:
<!--\(.\|^j\)*?-->
Note that the '^j' is actually entered by typing 'C-q C-j'.
This regular expression highlights the text correctly in re-builder,
but when I attempt to use it with M-x replace-regexp, it doesn't match
anything. I've tried a number of variations to no avail.
The intent of the regular expression is: "Match <!-- followed by
either any character that isn't a newline, or the newline character,
up to -->, but don't match past the > char." This last bit is
controlled by using non-greedy matching *? instead of the usual *.
Best,
Greg
next reply other threads:[~2012-03-28 22:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-28 22:03 Gregory Benjamin [this message]
[not found] <mailman.13.1332982418.20052.help-gnu-emacs@gnu.org>
2012-03-29 7:05 ` Help with regex including newline José A. Romero L.
-- strict thread matches above, loose matches on Subject: below --
2012-03-29 14:37 Buchs, Kevin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120328220313.GA1859@dbn66.laserlab.com \
--to=gregb@laserlab.com \
--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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.