qt中的正则是不匹配字符串
Regex in Qt not matching string it should
所以我有一个函数,让我们称其为getMatch。我写了一条以匹配它收到的字符串,但QT Regex引擎不像我期望的那样匹配。
为了演示,这是一些代码:
bool getMatch()
{
QString item = "BitwiseAND(Value, Mask)";
QRegExp rx("\w+\([\w+,\s]+?\)", Qt::CaseInsensitive);
return rx.exactMatch(item);
}
这应该每次都返回true,但它返回false。
我已经在在线测试人员中测试了正则表达式,应该没关系。
我认为您想要的是:
\w+\((\w+(?:,\s)?)+\)
您的正则是使用[
而不是(
,但这是一个字符类,而您正在做的只是分组和量化。。
相关文章:
- 我的求解(字符串 a、字符串 b)的输出与随机哈希中的预期输出不匹配
- (C++) 字符串文本与参数列表不匹配
- C++ 重载:[错误] 与'operator='不匹配(操作数类型为 'String' 和"字符串")
- 如何更有效地计算n个字符串之间的不匹配分数?
- 错误:尝试减去字符串时'operator-'不匹配
- 如何使用正则表达式提取字符串的不匹配部分
- 如何修复"运算符不匹配=="比较if语句中的字符串时
- qt中的正则是不匹配字符串
- C 等级不匹配多行字符串
- 正则表达式在开头单独匹配单词,或者在输入结束时通过不重复字符串附加到某些内容但附加到某些内容
- C++11 正则表达式与字符串不匹配
- 返回的字符串和提取的字符串不匹配
- 错误 C2308:连接不匹配的字符串
- 生成与集合中的字符串不匹配的字符串
- 一个不匹配的子字符串比较
- 有一个不匹配的字符串的算法
- 为什么这段代码在字符串中给出错误不匹配
- C++ regex_match match_continuous标志与开始子字符串不匹配
- Regex:返回完整字符串和不匹配的组
- 连接不匹配的字符串在VC2015工作-如何