[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacing two consecutive words where the two words could be separa
From: |
jpkotta |
Subject: |
Re: replacing two consecutive words where the two words could be separated by multiple spaces or newlines. |
Date: |
Sat, 18 Apr 2009 21:43:53 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Apr 17, 3:18 am, David Engster <d...@randomsample.de> wrote:
> Nobuko Three <nb...@yahoo.com> writes:
> > I wanted to replace all occurrences of `a integer' with `an integer' in a
> > latex file. But a simple query replace would replace the first `a integer'
> > of the following paragraph, but not the second one because the second one is
> > actually separated by a newline and two spaces (the indent).
>
> > This is a integer. That is a
> > integer. ...
>
> > What is an automated way to change paragraphs like above to paragraphs like
> > below?
>
> > This is an integer. That is an
> > integer. ...
>
> You can do this using regular expressions:
>
> M-x replace-regexp RET a\(\s-+\)integer RET an\1integer RET
>
> -David
I was curious about the "\s-" because I've never seen such a thing.
It sort of makes sense after RTFM, but it doesn't work all the time.
Is it equivalent to "[[:space:]]"? Apparently, it depends on the
major mode.
"a\([[:space:]^J]+\)integer" works for me, where "^J" is C-q C-j.