all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: replacing phrases: matching line feeds in regular expressions, since \s- doesn't work
Date: Sun, 19 Feb 2012 08:15:57 +0800	[thread overview]
Message-ID: <87zkcfwude.fsf@ericabrahamsen.net> (raw)
In-Reply-To: CAGk0Nk9=s_=uiZ1D6iOGz8hViR_PvM_W9yaamSbwNJ1SGqQSYA@mail.gmail.com

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




  parent reply	other threads:[~2012-02-19  0:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-18 17:52 replacing phrases: matching line feeds in regular expressions, since \s- doesn't work Steve Petersen
2012-02-18 19:17 ` Thorsten
2012-02-18 19:33 ` jeremiah.dodds
2012-02-18 20:44   ` Peter Dyballa
2012-02-19  2:47     ` jeremiah.dodds
2012-02-18 23:30   ` bitterspetey
2012-02-19  0:15 ` Eric Abrahamsen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-18 21:26 Silvio Levy
2012-02-19  3:04 ` jeremiah.dodds

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=87zkcfwude.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /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.