* query-replace-regexp ... "Invalid repacement string '\.'"
@ 2006-09-24 23:56 s. keeling
2006-09-25 6:33 ` Malte Spiess
2006-09-25 6:55 ` David Kastrup
0 siblings, 2 replies; 6+ messages in thread
From: s. keeling @ 2006-09-24 23:56 UTC (permalink / raw)
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.
So how do you replace '.' with '\.' in emacs? Googling's
(groups.google.com) turned up nothing useful (interesting, but not
useful). I tried variations of '\\\.' (literal backslash followed by
literal period) to no effect.
Suggestions or pointers welcome. Thanks.
--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://www.spots.ab.ca/~keeling Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
Spammers! http://www.spots.ab.ca/~keeling/emails.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: query-replace-regexp ... "Invalid repacement string '\.'"
2006-09-24 23:56 query-replace-regexp ... "Invalid repacement string '\.'" s. keeling
@ 2006-09-25 6:33 ` Malte Spiess
2006-09-25 7:02 ` David Kastrup
[not found] ` <85vencl9ar.fsf@lola.goethe.zz>
2006-09-25 6:55 ` David Kastrup
1 sibling, 2 replies; 6+ messages in thread
From: Malte Spiess @ 2006-09-25 6:33 UTC (permalink / raw)
"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.
A correct regexp for your intention should be
'[^\\]\.'
--
> So how do you replace '.' with '\.' in emacs?
That should be fine.
> Suggestions or pointers welcome. Thanks.
HTH
Malte
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: query-replace-regexp ... "Invalid repacement string '\.'"
2006-09-25 6:33 ` Malte Spiess
@ 2006-09-25 7:02 ` David Kastrup
[not found] ` <85vencl9ar.fsf@lola.goethe.zz>
1 sibling, 0 replies; 6+ messages in thread
From: David Kastrup @ 2006-09-25 7:02 UTC (permalink / raw)
[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
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <85vencl9ar.fsf@lola.goethe.zz>]
* Re: query-replace-regexp ... "Invalid repacement string '\.'"
[not found] ` <85vencl9ar.fsf@lola.goethe.zz>
@ 2006-09-25 7:14 ` Malte Spiess
0 siblings, 0 replies; 6+ messages in thread
From: Malte Spiess @ 2006-09-25 7:14 UTC (permalink / raw)
David Kastrup <dak@gnu.org> writes:
> 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.
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: query-replace-regexp ... "Invalid repacement string '\.'"
2006-09-24 23:56 query-replace-regexp ... "Invalid repacement string '\.'" s. keeling
2006-09-25 6:33 ` Malte Spiess
@ 2006-09-25 6:55 ` David Kastrup
2006-09-25 7:17 ` Malte Spiess
1 sibling, 1 reply; 6+ messages in thread
From: David Kastrup @ 2006-09-25 6:55 UTC (permalink / raw)
"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.
>
> So how do you replace '.' with '\.' in emacs? Googling's
> (groups.google.com) turned up nothing useful (interesting, but not
> useful). I tried variations of '\\\.' (literal backslash followed by
> literal period) to no effect.
>
> Suggestions or pointers welcome. Thanks.
M-x query-replace-regexp RET \. RET \\. RET
. is not special in the replacement string. You can also write
M-x query-replace-regexp RET \. RET \\\& RET
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: query-replace-regexp ... "Invalid repacement string '\.'"
2006-09-25 6:55 ` David Kastrup
@ 2006-09-25 7:17 ` Malte Spiess
0 siblings, 0 replies; 6+ messages in thread
From: Malte Spiess @ 2006-09-25 7:17 UTC (permalink / raw)
David Kastrup <dak@gnu.org> 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.
>>
>> So how do you replace '.' with '\.' in emacs? Googling's
>> (groups.google.com) turned up nothing useful (interesting, but not
>> useful). I tried variations of '\\\.' (literal backslash followed by
>> literal period) to no effect.
>>
>> Suggestions or pointers welcome. Thanks.
>
> M-x query-replace-regexp RET \. RET \\. RET
That would not work if there already is a "\" in the text. Your other
proposal is much better IMHO. (I think he does not want "\." to be
replaced with "\\.".)
I guess you just wanted to describe the general concept, this is just to
prevent confusion for other readers.
Greetings
Malte
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-09-25 7:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-24 23:56 query-replace-regexp ... "Invalid repacement string '\.'" s. keeling
2006-09-25 6:33 ` Malte Spiess
2006-09-25 7:02 ` David Kastrup
[not found] ` <85vencl9ar.fsf@lola.goethe.zz>
2006-09-25 7:14 ` Malte Spiess
2006-09-25 6:55 ` David Kastrup
2006-09-25 7:17 ` Malte Spiess
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.