From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthew Huggett Newsgroups: gmane.emacs.help Subject: Re: replacing strings Date: Tue, 18 Jan 2005 16:30:37 +0900 (JST) Message-ID: <20050118073037.A10AC197ED7@smtp2.att.ne.jp> References: <20050118062244.17606.qmail@web54405.mail.yahoo.com> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1106034830 23169 80.91.229.6 (18 Jan 2005 07:53:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Jan 2005 07:53:50 +0000 (UTC) Cc: Help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 18 08:53:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CqoBL-0004fU-00 for ; Tue, 18 Jan 2005 08:53:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CqoNE-0004uA-T9 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Jan 2005 03:06:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1CqoMq-0004tS-Fk for help-gnu-emacs@gnu.org; Tue, 18 Jan 2005 03:05:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1CqoKk-0004YE-TO for Help-gnu-emacs@gnu.org; Tue, 18 Jan 2005 03:03:28 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1CqoKa-0004TC-O6 for Help-gnu-emacs@gnu.org; Tue, 18 Jan 2005 03:03:16 -0500 Original-Received: from [165.76.15.138] (helo=smtp2.att.ne.jp) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cqnp5-0004dk-9H for Help-gnu-emacs@gnu.org; Tue, 18 Jan 2005 02:30:43 -0500 Original-Received: from MATT-DESKTOP (218.231.174.196.eo.eaccess.ne.jp [218.231.174.196]) by smtp2.att.ne.jp (Postfix) with ESMTP id A10AC197ED7; Tue, 18 Jan 2005 16:30:37 +0900 (JST) Original-To: senfunn@yahoo.com In-reply-to: <20050118062244.17606.qmail@web54405.mail.yahoo.com> (message from SENTHIL S on Mon, 17 Jan 2005 22:22:44 -0800 (PST)) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:23449 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:23449 > Date: Mon, 17 Jan 2005 22:22:44 -0800 (PST) > From: SENTHIL S > 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