在 RegEx 中,表达式 \X 匹配什么? [英] What does the expression \X match when inside a RegEx?

查看:52
本文介绍了在 RegEx 中,表达式 \X 匹配什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据http://www.regular-expressions.info

您可以将 \X 视为使用纯 ASCII 的正则表达式引擎中点的 Unicode 版本.

You can consider \X the Unicode version of the dot in regex engines that use plain ASCII.

这是否意味着它将匹配任何可能的Unicode代码点?

Does this mean that it will match any possible Unicode code point?

推荐答案

网站的描述很不错:

\X 匹配单个 Unicode 字素,无论是编码为单个代码点还是使用组合标记的多个代码点.字素最类似于字符"的日常概念.\X 匹配 à 编码为 U+0061 U+0300,à 编码为 U+00E0、© 等

\X Matches a single Unicode grapheme, whether encoded as a single code point or multiple code points using combining marks. A grapheme most closely resembles the everyday concept of a "character". \X matches à encoded as U+0061 U+0300, à encoded as U+00E0, ©, etc.

因此,使其能够识别 Unicode 的原因在于,当它们组合成一个可见的事物"(字素)时,它可以匹配多个代码点.

So, the thing that makes it Unicode-aware is that it can match several code points when those combine to a single visible "thing" (grapheme).

查看维基百科关于组合字符的页面了解更多详情,其中列出了提到的 U+0300 代码点上面,例如.

See Wikipedia's page on Combining Characters for more detail, it lists the U+0300 codepoint mentioned above, for instance.

这篇关于在 RegEx 中,表达式 \X 匹配什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆