[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp substitution
From: |
Friedrich Dominicus |
Subject: |
Re: elisp substitution |
Date: |
18 Jan 2003 18:35:32 +0100 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Native Windows TTY Support) |
matt <nwzmattXX@XXnetscape.net> writes:
> I'm just starting to play around with emacs lisp. A quick
> question. How can I manipulate variables in elisp? For instance, I
> want to take a string and add a backslash(escape) to all
> whitespace. Like in a path like
>
> "c:/Documents and settings/" I want to change it to
> "c:/Documents\ and\ Settings/".
>
> Something similar to this in perl: $var =~ s/( )/\\$1/g;
\ are unfine in Emacs lisp but here we go
(defvar *str* "c:\\Dokumente und Einstellungen\\")
(replace-in-string *str* (regexp-quote "\\") "/" )
"c:/Dokumente und Einstellungen/"
If I would not use regexp-quote I would have to write
"\\\\" the so calles scatterd tootpick syndrome ;-)
If you would just have nearly everything else it would be easier
Regards
Friedrich