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

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

Re: query-replace-regexp ... "Invalid repacement string '\.'"


From: David Kastrup
Subject: Re: query-replace-regexp ... "Invalid repacement string '\.'"
Date: Mon, 25 Sep 2006 09:02:54 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

[Oops, superseded]

Malte Spiess <i1tnews@arcor.de> writes:

> "s. keeling" <keeling@spots.ab.ca> 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.

> A correct regexp for your intention should be
> '[^\\]\.'
>    --
>
>> So how do you replace '.' with '\.' in emacs?
>
> That should be fine.

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).

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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