Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Isalpha, isalnum in Javascript? Date: Fri, 17 Jan 2020 21:10:06 +0000 Organization: A noiseless patient Spider Lines: 25 Message-ID: <87pnfhbxht.fsf@bsb.me.uk> References: <34ACCD99.539E361@apdo.com>#1/1> <98f3c647-877c-4602-b411-d319aee4b159@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="c99d7503adbdccdebf5829311e25c9e4"; logging-data="28268"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lWUW+I/HtaIP6gMWFB13338YiLbWaxn4=" Cancel-Lock: sha1:EtuXmdK/tMDHTrCRjBerw7gK2sc= sha1:CDOMEwyrY268+orJBPuLBO5IlfI= X-BSB-Auth: 1.dd3c9a07afdcf5ce8725.20200117211006GMT.87pnfhbxht.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:38080 ms.2052001@gmail.com writes: > On Friday, 2 January 1998 10:00:00 UTC+2, A.P. wrote: >> Hello, >> I would like to know if there's a way to check if a character is >> alphanumeric or if it belongs to a certain class of characters without >> having to check explicitly for all the cases with an endless if. I've >> tried with character>='A' and also with the Ascii code but I had no >> success. >> Please answer to my mailbox too. Thank you very much in advance. > > > You can use regex expressions to check, but it will check for English letters, > code: > var isAlpha = (c) => (/[A-Za-z]/).test(c); If you have ECMAScript 9, you can use /\p{Letter}/u as the pattern to match all Unicode characters with property General_Category = Letter. Still not 100%, but it might be what's wanted. -- Ben.