JavaScript + Unicode regexes

前端 未结 11 1133
星月不相逢
星月不相逢 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:45

    If you are using Babel then Unicode support is already available.

    I also released a plugin which transforms your source code such that you can write regular expressions like /^\p{L}+$/. These will then be transformed into something that browsers understand.

    Here is the project page of the plugin:

    babel-plugin-utf-8-regex

提交回复
热议问题