3

在 JavaScript 中,我们可以使用 Unicode 转义序列匹配单个 Unicode 代码点或代码点范围,例如:

"A".match(/\u0041/) // => ["A"]
"B".match(/[\u0041-\u007A]/) // => ["B"]

但是我们如何使用 JavaScript 正则表达式创建一个正则表达式来匹配必须包含任何 Unicode“字母”的专有名称?有字母范围吗?JavaScript 中的特殊正则表达式序列或字符类?

假设我的网站必须验证可能是基于拉丁语的名称以及希伯来语、西里尔语、日语(片假名、平假名等)的名称,这在 JavaScript 中是否可行,或者是委托给具有更好 Unicode 支持的后端语言的唯一明智选择?

4

2 回答 2

5

这是一个为 RegEx 添加 Unicode 支持的 JS 插件

http://xregexp.com/plugins/

于 2011-04-06T18:29:47.363 回答
0

我正在使用该站点http://www.fileformat.info定义符号的 unicode 。

Unicode 块(基本拉丁文、.+、西里尔文、.+、阿拉伯文和其他): http ://www.fileformat.info/info/unicode/block/index.htm

Unicode 字符类别(这在 JS 中不起作用): http ://www.fileformat.info/info/unicode/category/index.htm

字母(A-я): http ://www.fileformat.info/info/unicode/char/a.htm

字体(每种字体支持哪些字符): http ://www.fileformat.info/info/unicode/font/index.htm

以上所有索引 http://www.fileformat.info/info/unicode/index.htm

于 2011-04-07T12:06:57.403 回答