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

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

Re: replace-regexp question


From: lawrence mitchell
Subject: Re: replace-regexp question
Date: Mon, 02 Jun 2003 12:53:29 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50

Chang Luo wrote:

> I want to replace regexp "a$" to "a$b$c$".  how to do that?

> i.e.  I want:
> a    ->     a
>             b
>             c

> But replace-regexp gives me:
> a   ->      a$b$c$

"$" is only a special character in regexps in the search string
(not the replace string).  Hence, you want to do something like
(replace-regexp "a$" "a\nb\nc\n").  If doing this interactively,
"\n" is also interpreted literally.  So you have to insert an
literal newline, using C-q C-j, e.g. the interactive key
sequence would be:

M-x replace-regexp RET a $ RET a C-q C-j b C-q C-j c C-q C-j RET


hope the clears that up a bit.
-- 
lawrence mitchell <address@hidden>


reply via email to

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