如何检查字符是否是Javascript中的字母?
我通过以下方式提取Javascript字符串中的字符:
I am extracting a character in a Javascript string with:
var first = str.charAt(0);
,我想检查它是否是一封信。奇怪的是,它似乎并不像这样的功能存在于Javascript。至少我找不到。
and I would like to check whether it is a letter. Strangely, it does not seem like such functionality exists in Javascript. At least I cannot find it.
如何测试这个?
我相信此插件具有您所寻求的功能: http://xregexp.com/plugins/ ( github链接: https://github.com/slevithan/xregexp )
I believe this plugin has the capabilities you seek: http://xregexp.com/plugins/ (github link: https://github.com/slevithan/xregexp)
有了它,你可以简单地匹配所有unicode字母与 \p {L}
。
With it you can simply match all unicode letters with \p{L}
.
阅读此源文件的标题,以查看其支持的类别: http:// xregexp .com / plugins / xregexp-unicode-categories.js
Read the header of this source file to see which categories it supports: http://xregexp.com/plugins/xregexp-unicode-categories.js