unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Regexp: match any character including newline
@ 2013-10-16 14:42 Yuri Khan
  2013-10-16 15:31 ` Kai Großjohann
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yuri Khan @ 2013-10-16 14:42 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

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&shy;Insert&shy;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&shy;Insert&shy;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 :)



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-10-17  2:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4131.1381934579.10748.help-gnu-emacs@gnu.org>
2013-10-16 15:58 ` Regexp: match any character including newline 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
2013-10-16 14:42 Yuri Khan
2013-10-16 15:31 ` Kai Großjohann
2013-10-16 15:56   ` Yuri Khan
2013-10-16 16:53 ` Drew Adams
2013-10-17  2:25 ` Eric Abrahamsen

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