From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Malte Spiess Newsgroups: gmane.emacs.help Subject: Re: query-replace-regexp ... "Invalid repacement string '\.'" Date: Mon, 25 Sep 2006 09:14:01 +0200 Organization: Arcor Message-ID: <87hcyw2zba.fsf@trick.ulm.malte.spiess> References: <87hcyw78w3.fsf@trick.ulm.malte.spiess> <85vencl9ar.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1159170367 17552 80.91.229.2 (25 Sep 2006 07:46:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 25 Sep 2006 07:46:07 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 25 09:46:04 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GRlA9-0000Rq-KY for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Sep 2006 09:46:01 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GRlA9-0001Vy-7n for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Sep 2006 03:46:01 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:cOHgfnwUdS00sE+1jRlWPh1EQck= Original-Lines: 42 Original-NNTP-Posting-Date: 25 Sep 2006 09:13:54 CEST Original-NNTP-Posting-Host: fcdf85f0.newsspool3.arcor-online.net Original-X-Trace: DXC=T?l7P\P:22WAX0F2i> 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: news.gmane.org gmane.emacs.help:37603 Archived-At: David Kastrup writes: > Malte Spiess writes: > >> "s. keeling" writes: >> >>> Hi. I was trying to make it easy on myself using q-r-r replacing >>> '[^\]\.' (not a backslash, followed by a literal dot/period) with the >>> string (sans quotes) '\.', essentially "escaping" every dot/period in >>> the file. "M-x query-replace" had no trouble with it but M-x >>> query-replace-regexp refused, spouting the error message in the >>> subject. >> >> In a regexp for a "\" you need to escape, so write "\\". "\]" is a >> mistake. > > No, it isn't. Inside of [], \ is not special. Oh. Oops, sorry. Must admit I never used "\" inside of []. Didn't expect a change there. > Maybe something like > > M-x query-replace-regexp RET \(^\|[^\]\). RET \1\\. RET > > Or even > > M-x query-replace-regexp RET \(\(^\|[^\]\)\(\\\\\)*\). RET \1\\. RET > > (which considers a dot preceded by an even number of backslashes as > unescaped). In case he wants to replace the character before the "." as well (which I doubt) '\\.' as a replacement string should do fine. Else the proposed constructions with \(...\) and \1 (sometimes even \2 or \3) should work fine. This is a really useful feature, one should learn how to use it to simplify lots of replacement tasks. Greetings Malte