Reputation: 314
So I have a function, lets call it getMatch. I wrote a regex to match a string that it receives but the Qt regex engine isn't matching it like I expect it to.
For demonstrations sake, here is some code:
bool getMatch()
{
QString item = "BitwiseAND(Value, Mask)";
QRegExp rx("\\w+\\([\\w+,\\s]+?\\)", Qt::CaseInsensitive);
return rx.exactMatch(item);
}
This should return true every time, but it returns false.
I have tested the regex in online testers, and it should be fine.
Upvotes: 0
Views: 181
Reputation: 7351
I think what you want is this:
\\w+\\((\\w+(?:,\\s)?)+\\)
your regex is using [
instead of (
, but that's a character class, whereas what you are doing is simply grouping and quantifying.
Upvotes: 2