all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Florian Kaufmann" <sensorflo@gmail.com>
Subject: Re: regexp question
Date: 27 Sep 2006 00:58:10 -0700	[thread overview]
Message-ID: <1159343890.543389.316230@k70g2000cwa.googlegroups.com> (raw)
In-Reply-To: <mailman.7422.1159272599.9609.help-gnu-emacs@gnu.org>


>  i want to replace a block beginning with <column_right> and ending with
> </column_right>, with a variable number of lines between with another
> text block. ext block with a regular expression?

I would use:

<column_right>\(.\|^J\)*?</column_right>

Where the ^J results from pressing C-q C-j.

The details: Since the dot . does much any character but the newline, I
use the construct \(.\|^J\) which now matches really any character. *?
is the lazy version of the greedy *. Meaning that as few as possible
are selected. This prevents from selecting too much. Only * instead of
*? would much both of the following lines instead of only one.

<column_right>line1</column_right>
<column_right>line2</column_right>

However, my regex fails to match nested tags. In the following example
<column_right><column_right></column_right></column_right>

the match is
<column_right><column_right></column_right>

which is not what you want. I don't know how to make a regular
expression which would also support this case. I'm sure you would find
the answer in the book "Mastering regular expressions"

Flo

  parent reply	other threads:[~2006-09-27  7:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7384.1159203371.9609.help-gnu-emacs@gnu.org>
2006-09-26  0:52 ` replace a textblock in multiple files Benjamin Rutt
2006-09-26 11:18   ` AW: " C.Strobl
2006-09-26 12:09     ` regexp question C.Strobl
2006-09-26 17:16       ` Peter Dyballa
2006-09-29 22:03         ` Dieter Wilhelm
2006-09-30  8:53           ` Peter Dyballa
     [not found]     ` <mailman.7422.1159272599.9609.help-gnu-emacs@gnu.org>
2006-09-27  7:58       ` Florian Kaufmann [this message]
2011-01-06 16:14 Thorsten Bonow
2011-01-07 10:05 ` tomas
     [not found] <20040924194238.40080.qmail@web51606.mail.yahoo.com>
2004-09-28 18:21 ` RegExp question JayBingham
  -- strict thread matches above, loose matches on Subject: below --
2004-09-23 20:23 JayBingham
2004-09-24 19:43 ` Ryan Bowman
     [not found] <mailman.3776.1095958718.1998.help-gnu-emacs@gnu.org>
2004-09-23 18:09 ` Stefan Monnier
2004-09-23 16:41 Ryan Bowman
2004-09-23 18:05 ` Greg Hill

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=1159343890.543389.316230@k70g2000cwa.googlegroups.com \
    --to=sensorflo@gmail.com \
    /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.