You would probably want to use the charCodeAt() function on the string.
Assuming you want to search for printable, latin characters, the codes
would be 65 - 90 (upper case A-Z) and 97 - 122 (lower case a-z).
if ((letter.charCodeAt(0) >= 65) && (letter.charCodeAt(0) <= 90)) ||
((letter.charCodeAt(0) >= 97) && (letter.charCodeAt(0) <= 122))
{
stuff
}
If you don't care if you catch the printable characters of [\]^_` you
could just use the range of 65 -> 122. A full ASCII code table is at
http://ascii-table.com/ascii.php (or if you have an MS-DOS book
available)
-Nick
On Sun, Apr 21, 2013 at 9:05 PM, Justin Mclean <[email protected]>wrote:
> Hi,
>
> Anyone know how to work out if a character, including unicode characters,
> is a letter or not?
>
> This is not the right way of doing it:
>
> if ("a" <= letter && letter <= "z" ||
> "A" <= letter && letter <= "Z")
>
> From the DateFormatter class for the curious.
>
> Thanks,
> Justin
>
>
>
>