From: Yuri Khan <yuri.v.khan@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Regexp: match any character including newline
Date: Wed, 16 Oct 2013 21:42:54 +0700 [thread overview]
Message-ID: <CAP_d_8Vj6Wa6OXP_73jxaZOM3U6cw8sc2zHkae5gfgVR6to2mg@mail.gmail.com> (raw)
Hello All,
I’m doing regexp replacements on a hard-wrapped XHTML-alike. Here’s an
original fragment:
===
<tr><td><pre><code>X(n, t)
X a(n, t)</code></pre></td><td></td>
<td><requires><p><code>T</code> shall be
<concept>Copy­Insert­able</concept> into
<code>X</code>.</p></requires>
<p>post: <code>distance(begin(), end()) == n</code></p>
<p>Constructs a sequence container with <code>n</code> copies
of <code>t</code></p></td></tr>
===
Here’s what I need to turn it into:
===
<expression><pre><code>X(n, t)
X a(n, t)</code></pre></expression>
<return_type></return_type>
<assertion_note><requires><p><code>T</code> shall be
<concept>Copy­Insert­able</concept> into
<code>X</code>.</p></requires>
<p>post: <code>distance(begin(), end()) == n</code></p>
<p>Constructs a sequence container with <code>n</code> copies
of <code>t</code></p></assertion_note>
===
To this end, I want to do a regexp replace of:
===
<tr><td>\(.*?\)</td><td>\(.*?\)</td>
<td>\(.*?\)</td></tr>
===
with
===
<expression>\1</expression>
<return_type>\2</return_type>
<assertion_note>\3</assertion_note>
===
except that “.” needs to match any character including newline.
I know the obvious solution: instead of “.”, use the following monstrosity:
===
\(?:.\|
\)
===
However, I find that very cumbersome to type, especially since I have
to press C-q C-j in between.
Is there a way to make “.” match newline too, or is there an easier
way to match any character including newline? (I don’t want to limit
myself to [:ascii:] as there are also Unicode-specific dashes.)
For now, I’ve devised a workaround of using [^@] where @ is a
character that does not occur in the text. Maybe [^^] since it’s
easier to type and looks cute :)
next reply other threads:[~2013-10-16 14:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-16 14:42 Yuri Khan [this message]
2013-10-16 15:31 ` Regexp: match any character including newline Kai Großjohann
2013-10-16 15:56 ` Yuri Khan
2013-10-16 16:53 ` Drew Adams
2013-10-17 2:25 ` Eric Abrahamsen
[not found] <mailman.4131.1381934579.10748.help-gnu-emacs@gnu.org>
2013-10-16 15:58 ` Rustom Mody
2013-10-16 16:16 ` Yuri Khan
[not found] ` <mailman.4141.1381940186.10748.help-gnu-emacs@gnu.org>
2013-10-16 16:48 ` Rustom Mody
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=CAP_d_8Vj6Wa6OXP_73jxaZOM3U6cw8sc2zHkae5gfgVR6to2mg@mail.gmail.com \
--to=yuri.v.khan@gmail.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.