如何将连续的unicode与QRegExp匹配?

发布于 2024-12-22 23:11:44 字数 254 浏览 3 评论 0原文

我检查了Qt的文档,它完全支持unicode与\xhhhh的匹配,但是这样我只能匹配已知的unicode,那么我如何识别unicode字符串呢?

谢谢 !

@update:

QString line;
if ( line.indexOf(QRegExp ("\\p{L}")) ) != -1 )
{
 /// blabla
}

它不起作用,我没有看到流程进入 if

I checked Qt's doc , it fully support matching of unicode with \xhhhh , but in that way i can only match known unicodes , how can i recognize a unicode string then ?

Thanks !

@update:

QString line;
if ( line.indexOf(QRegExp ("\\p{L}")) ) != -1 )
{
 /// blabla
}

It's not working , i didn't see the flow went inside the if

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断桥再见 2024-12-29 23:11:44

我不知道 Qt 正则表达式,但根据 doc

QRegExp 是根据 Perl 的正则表达式语言建模的。它完全支持 Unicode。

我认为它应该支持 Unicode 属性、脚本和块。有关详细概述,请参阅 www.regular-expressions.info

例如,您可以使用属性字母 \p{L} 将 unicode 代码点与属性字母进行匹配。要匹配仅包含此类代码点的字符串,请使用类似以下内容

^\p{L}+$

I Don't know Qt regular expresions, but according to the doc

QRegExp is modeled on Perl's regexp language. It fully supports Unicode.

I would assume that it should then support Unicode Properties, Scripts and Blocks. For a detailed overview see www.regular-expressions.info.

You could e.g. use the property letter \p{L} to match a unicode codepoint with the property letter. To match a string consisting only of such code points use something like this

^\p{L}+$
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文