gpt4 book ai didi

regex - QRegExp如何匹配连续的unicode?

转载 作者:行者123 更新时间:2023-12-05 01:15:42 24 4
gpt4 key购买 nike

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

谢谢!

@更新:

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

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

最佳答案

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

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

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

例如,您可以使用属性字母 \p{L} 将 unicode 代码点与属性字母匹配。要匹配仅由此类代码点组成的字符串,请使用类似这样的东西

^\p{L}+$

关于regex - QRegExp如何匹配连续的unicode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8611656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com