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: Thorsten
Subject: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work
Date: Sat, 18 Feb 2012 20:17:35 +0100
User-agent: Gnus/5.130002 (Ma Gnus v0.2) 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?

My uninformed and untested opinion is to just use M-x query-replace,
since you want to replace a string with another string. Maybe it doesn't
match when a line break is involved, but I would be surprised. 

Another possibility would be to use M-x regexp-builder, a tool that
helps you to visualize the matches for your regexp. 

cheers
--
Thorsten




reply via email to

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