help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: end-of-line $ in multiline regexp replace


From: Edward Dodge
Subject: Re: end-of-line $ in multiline regexp replace
Date: Fri, 31 Oct 2003 10:50:07 -0600
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (darwin)

"Leo" <leo.broska@NOSPAM.isys.com.au> writes:

> hi there
>
> want to replace a multiline regexp by an one-line replacement. (in fact i
> just want to delete the line with the regexp.)
>
> so, at first i tried:
>         (query-replace-regexp ".*bytes.*$[ctrl-q][ctrl-j]" "" nil nil nil)
> which did not find any line. :-(
>
> then i just tried the same without the end-of-line "$":
>         (query-replace-regexp ".*bytes.*[ctrl-q][ctrl-j]" "" nil nil nil)
> and that worked.
>
> i don't understand, why? the first regexp ".*bytes.*$[ctrl-q][ctrl-j]" seems
> to me even >>more valid<< then the second one.
>
> any explanations?
>
> tanks and cheers, leo

The $ meta-character represents the very end of a line, which would
include the newline character.  Whereas C-q C-j is a regular
expression for the newline character.  My guess is that $ marks the
very end of the line (INCLUDING the newline character) and so your
regexp is actually the equivalent of this:

".*bytes.*[ctrl-q][ctrl-j][ctrl-q][ctrl-j]"

-- 
Edward Dodge

/GNU Emacs 21.3.50.1 (powerpc-apple-darwin5.5) of 2002-10-11 on G3/


reply via email to

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