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: jeremiah . dodds
Subject: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work
Date: Sat, 18 Feb 2012 14:33:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux)

Steve Petersen <steve@stevepetersen.net> writes:

> 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?

The following works for me with the words separated by arbitrary
whitespace including newlines (although it is ugly, and I'm sure there's
better ways to do it):

M-x replace-regexp foo[ ^TAB^j]*bar[ ^TAB^j]*baz[ ^TAB^j] RET fbb RET

Where ^TAB and ^j are C-qTAB and C-qC-j, on 24.0.93.8. I don't know, but
I don't think that it should behave significantly differently on 23.




reply via email to

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