From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: regex question Date: Mon, 19 May 2003 19:07:09 GMT Organization: Genuity Managed Services, Woburn, MA Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87znljuide.fsf@web.de> NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1053375309 31238 80.91.224.249 (19 May 2003 20:15:09 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 19 May 2003 20:15:09 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Mon May 19 22:15:05 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Hr2G-00087a-00 for ; Mon, 19 May 2003 22:15:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 19Hq2M-0003Ct-02 for gnu-help-gnu-emacs@m.gmane.org; Mon, 19 May 2003 15:11:06 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!news.compaq.com!paloalto-snf1.gtei.net!mtvwca1-snh1.ops.genuity.net!crtntx1-snh1.gtei.net!news.gtei.net!paloalto-snr1.gtei.net.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 44 Original-X-Trace: +rnM+l+GVQGRXfScSmdNR5vTdThAbHKTIOzoIdlHZy4sb7fIp9oDEcHbJWWyqBuB4lfm5wwg1IYN!VItzDYVOQre705lUYZolmjflBrXLgKufVSLnEI1oSCqGsOkbbvRm2W3qO9ODVCLBGiqVeO4Oub8B!R7C7R0asHRObDw== Original-X-Complaints-To: abuse@gte.net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Original-NNTP-Posting-Date: Mon, 19 May 2003 19:07:09 GMT Original-Distribution: world Original-Xref: shelby.stanford.edu gnu.emacs.help:113397 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:9891 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:9891 In article <87znljuide.fsf@web.de>, upro wrote: >This might be a stupid question: > >I want to use M-x replace-regexp like this > >s/[a-z]''/$1"/g > >the first part [a-z]'' works, but then the mathed lowercase letter is >not reinserted, but a litteral $1. If you want to grab a part of the matched text, you should use \, etc.; $ is Perl's equivalent, but most other regexp packages use \. Also, you need to put parentheses around the part that you want it to remember. So it should be: Old: \([a-z]\)'' New: \1" >How does that work in emacs-regex? I don't find the relevant info in >the info file... File: emacs, Node: Regexp Replace Regexp Replacement ------------------ The `M-x replace-string' command replaces exact matches for a single string. The similar command `M-x replace-regexp' replaces any match for a specified pattern. In `replace-regexp', the NEWSTRING need not be constant: it can refer to all or part of what is matched by the REGEXP. `\&' in NEWSTRING stands for the entire match being replaced. `\D' in NEWSTRING, where D is a digit, stands for whatever matched the Dth parenthesized grouping in REGEXP. To include a `\' in the text to replace with, you must enter `\\'. For example, -- Barry Margolin, barry.margolin@level3.com Genuity Managed Services, a Level(3) Company, Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.