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

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

Re: How to convert an arbitrary string into a filename


From: Platon Pronko
Subject: Re: How to convert an arbitrary string into a filename
Date: Wed, 26 Apr 2023 12:03:02 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1

On 2023-04-26 11:55, Marcin Borkowski wrote:
Hi all,

given an arbitrary string, say "Hello, world!!!", I want to have
a filename with all the runs of weird characters (that is,
non-alphanumeric ones) converted to dashes (say, "Hello-world").  Is
there a function for that in Emacs already or should I write my own?

Something like this?

(let ((input "Hello, world!!!"))
  (replace-regexp-in-string "[^a-zA-Z0-9]+" "-" input))
;; "Hello-world-"

--
Best regards,
Platon Pronko
PGP 2A62D77A7A2CB94E




reply via email to

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