[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using replace-regexp doesn't remove newlines?
From: |
David Kastrup |
Subject: |
Re: Using replace-regexp doesn't remove newlines? |
Date: |
Fri, 15 Jul 2005 14:42:06 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
"ozark" <shreevatsa@gmail.com> writes:
> Some of the lines in the buffer have only the single character '#' in
> them. I want to remove all such lines.
> I tried doing the following:
>
> M-x replace-regexp ^#$<RET><RET>
> This replaces the lines with # in them by blank lines. As this is not I
> want, I undid that, and instead tried
>
> M-x replace-regexp ^#$C-qC-j<RET><RET>
> This just says "Replaced 0 occurrences" and does nothing. Why is this
> so? (I also tried C-m instead of C-j, it doesn't work either. I'm using
> Linux)
Leave off the $. It is described in
(info "(emacs)Regexps")
`$'
is similar to `^' but matches only at the end of a line. Thus,
`x+$' matches a string of one `x' or more at the end of a line.
For historical compatibility reasons, `$' can be used with this
meaning only at the end of the regular expression, or before `\)'
or `\|'.
And the C-q C-j is quite enough to match the end of line.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum