【发布时间】:2013-06-25 02:00:58
【问题描述】:
我正在尝试使用正则表达式检测希伯来语字符。根据我的阅读,这是 Unicode 范围内的任何字符 0x0590-0x05ff。
但是,以下方法不起作用:
// Character code \u05e6
var c = String.fromCharCode(parseInt('05e6', 16));
/[\u0590–\u05ff]/.test(c); // false
但以下确实有效:
// Character code \u05e6
var c = String.fromCharCode(parseInt('05e6', 16));
/[\u0590–\u05e8\u05e9-\u05ff]/.test(c); // true
为什么?为什么我必须将范围拆分为0x0590-0x05e8 加上0x05e9-0x05ff?
我在 Chrome 和 Firefox 中的 JavaScript 中对此进行了测试,它们都有相同的行为。
【问题讨论】:
标签: javascript regex internationalization