Regex for all alphabets

后端 未结 3 661
孤街浪徒
孤街浪徒 2021-01-24 03:11

i need a regex for all alphabets. I have an input and target text. Both of them can be belong different alphabets. I mean they can be belong chinese, latin, cyrillic and any oth

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-24 03:35

    If you are in Java (not in javascript!) you can use unicode properties, e.g.

    \P{L} any kind of letter from any language.

    See regular-expressions.info/unicode for more informations.

    For Javascript:

    There is a lib from XRegExp and some plugins XRegExp Unicode plugins that extends the javasript regex features. That adds support for Unicode categories, scripts, and blocks.

    With those libs you would be able to use \p{L} with javascript.

    See my answer to this question for a small example

提交回复
热议问题