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

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

Re: reduce repeated backslashes


From: Teemu Likonen
Subject: Re: reduce repeated backslashes
Date: Mon, 15 Feb 2010 10:51:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

* 2010-02-15 09:40 (+0100), Andreas Roehler wrote:

> don't know how to replace/reduce repeated backslashes from inside a
> string.
>
> Let's assume "abcdef\\\\"

What is the end result you want? I guess:

    (replace-regexp-in-string "\\\\\\\\" "\\" "abcdef\\\\" nil t)
    => "abcdef\\"

There are 8 backslashes in the regexp string because backslash is a meta
character in Lisp strings and also in regexps. 8 backslashes in a regexp
Lisp string means 2 literal backslashes. In the resulting string there
is only one backslash but it is displayed as two "\\" because it's a
printed representation of Lisp string.


reply via email to

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