[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reduce repeated backslashes
From: |
Andreas Röhler |
Subject: |
Re: reduce repeated backslashes |
Date: |
Mon, 15 Feb 2010 12:55:49 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
Teemu Likonen wrote:
> * 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.
>
Thanks all!
Andreas