all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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
[parent not found: <mailman.4131.1381934579.10748.help-gnu-emacs@gnu.org>]

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 --
2013-10-16 14:42 Regexp: match any character including newline 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
     [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

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.