Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38080

Re: Isalpha, isalnum in Javascript?

Path csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
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> (permalink)
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

Show key headers only | View raw


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.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Isalpha, isalnum in Javascript? ms.2052001@gmail.com - 2020-01-17 00:50 -0800
  Re: Isalpha, isalnum in Javascript? JJ <jj4public@vfemail.net> - 2020-01-17 23:05 +0700
    Re: Isalpha, isalnum in Javascript? dr.j.r.stockton@gmail.com - 2020-01-17 13:07 -0800
      Re: Isalpha, isalnum in Javascript? JJ <jj4public@vfemail.net> - 2020-01-18 21:01 +0700
        Re: Isalpha, isalnum in Javascript? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-01-18 19:13 +0100
  Re: Isalpha, isalnum in Javascript? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 21:10 +0000
    Re: Isalpha, isalnum in Javascript? dr.j.r.stockton@gmail.com - 2020-01-18 02:42 -0800
      Re: Isalpha, isalnum in Javascript? JJ <jj4public@vfemail.net> - 2020-01-18 21:01 +0700
      Re: Isalpha, isalnum in Javascript? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-18 12:13 -0800
    Re: Isalpha, isalnum in Javascript? Julio Di Egidio <julio@diegidio.name> - 2020-01-19 10:07 -0800
      Re: Isalpha, isalnum in Javascript? dr.j.r.stockton@gmail.com - 2020-01-19 15:39 -0800
        Re: Isalpha, isalnum in Javascript? Julio Di Egidio <julio@diegidio.name> - 2020-01-19 15:45 -0800

csiph-web