JavaScript + Unicode regexes

前端 未结 11 1111
星月不相逢
星月不相逢 2020-11-21 05:11

How can I use Unicode-aware regular expressions in JavaScript?

For example, there should be something akin to \\w that can match any code-point in Lette

11条回答
  •  不知归路
    2020-11-21 05:42

    This will do it:

    /[A-Za-z\u00C0-\u00FF ]+/.exec('hipopótamo maçã pólen ñ poção água língüa')
    

    It explicitly selects a range of unicode characters. It will work for latin characters, but other strange characters may be out of this range.

提交回复
热议问题