help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiline regex


From: Valentin Baciu
Subject: Re: Multiline regex
Date: Mon, 21 Nov 2011 17:54:39 +0200

Hello,

You are probably calling the `replace-regexp' interactively. Try to replace the regexp with: 
a\(.*
?\)*?*b

Otherwise, calling (replace-regexp "a\\(.*
?\\)*?*b", "") from code, in the buffer containing your text should work as expected.

I think this is happening because how strings are being read and escaped. In one case you need the \\ since you are calling the function from code and the backslash has to be escaped. But, when called interactively (using M-x) you are already passing an "escaped" backslash, so one is sufficient.

On Mon, Nov 21, 2011 at 3:56 PM, Giles Chamberlin <address@hidden> wrote:
I'm having trouble with a multi line regex: can any one show me where
I'm going wrong?

I have a data file of the form:

a
1
b

a
2
b

and wish to replace the "paragraphs" a..b.  Using re-builder (and based
on http://www.emacswiki.org/emacs/MultilineRegexp) I have constructed a
successfully matching regex:

"a\\(.*
?\\)*?*b"

but when I try to use that regex in replace-regex I get 0 matches.  Any
suggestions?




--
Giles




reply via email to

[Prev in Thread] Current Thread [Next in Thread]