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

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

Re: How to check whether a character (or one-character string) is a lett


From: Eric Abrahamsen
Subject: Re: How to check whether a character (or one-character string) is a letter?
Date: Sat, 04 Oct 2014 10:58:44 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Marcin Borkowski <mbork@wmi.amu.edu.pl> writes:

> Hello,
>
> this is a problem I have.
>
> Assume that I have a character (taken from some string, which in turn is
> copied from the buffer - so it need not be ASCII).  What is the best way
> to check whether it is a letter within ASCII range?
>
> The reason I'm asking is that I'm writing a function which converts an
> arbitrary string to a valid (and nice) filename (e.g., only letters and
> hyphens) - so basically I want to walk a string character by character
> and convert any space to a hyphen and omit any other non-letter.  Am I
> reinventing the wheel?

The safest thing is probably still replace-regexp-in-string. You can use
the [:ascii:] character class to strip out anything that isn't ascii,
with a regexp like "[^[:ascii:]]+". Messing with the string at the
character level shouldn't be necessary.

Eric




reply via email to

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