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

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

Re: replacing phrases: matching line feeds in regular expressions, since


From: Eric Abrahamsen
Subject: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work
Date: Sun, 19 Feb 2012 08:15:57 +0800
User-agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.0.93 (gnu/linux)

On Sun, Feb 19 2012, Steve Petersen wrote:

> Hi emacs gurus,
>
> [I accidentally posted this first to the main emacs forum, pardon my
> newbness.]
>
> I've spent hours scouring the web trying to solve what should be a
> simple problem.  I appreciate any help! 
>
> I want to replace a three-word phrase with an acronym.  Should be
> easy, right?  But of course I want to match across lines.  From what
> I read '\s-' should match line feeds, but it doesn't.  The closest
> I've gotten to matching across lines is using 'foo[\s-^J]+bar' (using
> ^Q to insert ^J literally), but for some reason that doesn't match
> 'foo bar' on the same line!  I'm out of ideas - what's going on?

There are also char classes, which gives you [:space:], matching both
space and tab (it would be really nice to have one class that matches
space, tab and newline...). So you could do:

"foo[[:space:]^J]bar[[:space:]^J]baz[[:space:]^J]?"

That seems to work, though it's still ugly.

-- 
GNU Emacs 24.0.93.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-02-16 on pellet




reply via email to

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