How to check if character is a letter in Javascript?

前端 未结 13 1590
渐次进展
渐次进展 2020-11-27 14:38

I am extracting a character in a Javascript string with:

var first = str.charAt(0);

and I would like to check whether it is a letter. Stran

相关标签:
13条回答
  • 2020-11-27 15:38

    I believe this plugin has the capabilities you seek: http://xregexp.com/plugins/ (github link: https://github.com/slevithan/xregexp)

    With it you can simply match all unicode letters with \p{L}.

    Read the header of this source file to see which categories it supports: http://xregexp.com/plugins/xregexp-unicode-categories.js

    0 讨论(0)
提交回复
热议问题