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

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

Re: replacing strings


From: Matthew Huggett
Subject: Re: replacing strings
Date: Tue, 18 Jan 2005 16:30:37 +0900 (JST)

>    Date: Mon, 17 Jan 2005 22:22:44 -0800 (PST)
>    From: SENTHIL S <senfunn@yahoo.com>
>    Content-Type: text/plain; charset=us-ascii
>    Cc: 
>    Sender: help-gnu-emacs-bounces+mhuggett=zam.att.ne.jp@gnu.org
> 
>    hi,
>    How to replace a string with the same string+something
>    ..
> 
>    eg: sum - [sum]
>        moon - [moon]
>    thanks

Use parentheses in a regular expression to capture part of the match.
For example, for the simple cases you have give, you might try:

    M-x replace-regexp

and give \(\w+\b\) for the regexp and [\1] for the replacement.  The
\1 will give you whatever was captured by the () in the regexp.


Matthew




reply via email to

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