From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: reduce repeated backslashes
Date: Mon, 15 Feb 2010 10:12:12 +0100 [thread overview]
Message-ID: <87r5omj21f.fsf@tux.homenetwork> (raw)
In-Reply-To: 87vddyj2ew.fsf@tux.homenetwork
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Andreas Roehler <andreas.roehler@online.de> writes:
>
>> Hi,
>>
>> don't know how to replace/reduce repeated backslashes
>> from inside a string.
>>
>> Let's assume "abcdef\\\\"
>>
>> Tried
>>
>> (replace-regexp-in-string "\\\\" (number-to-string ?\\) "abcdef\\\\" nil t)
>>
>> which reduces so far, but shows chars as it's numeric value:
>>
>> --> "abcdef9292"
>>
>> Any help? Thanks!
>
> What result do you expect?
>
> `number-to-string' give the string value of a number:
>
> eval:
> ?\\ ==> 92
> (number-to-string ?\\) ==> "92"
>
> `string' will give you the real value of ?char:
> eval:
> (string ?\\) ==> "\\"
>
> May be a better approach is:(if it is what you expect)
>
> (substring "abcdef\\\\" 0 7)
> "abcdef\\"
However:
(replace-regexp-in-string "\\\\\\\\" (string ?\\) "abcdef\\\\" nil t)
==> "abcde\\"
--
Thierry Volpiatto
next prev parent reply other threads:[~2010-02-15 9:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-15 8:40 reduce repeated backslashes Andreas Roehler
2010-02-15 9:03 ` Peter Dyballa
2010-02-15 9:04 ` Thierry Volpiatto
2010-02-15 9:12 ` Thierry Volpiatto [this message]
[not found] <mailman.1267.1266223114.14305.help-gnu-emacs@gnu.org>
2010-02-15 8:51 ` Teemu Likonen
2010-02-15 11:55 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r5omj21f.fsf@tux.homenetwork \
--to=thierry.volpiatto@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).