Solved Called on an invalid QRegularExpression object warning
-
QRegularExpression re2("^=?[a-z1-9A-Z\s+-*/]*");
QRegularExpressionMatch mat = re2.match(tst);The above code generated called on an invalid QRegularExpression object warning, while the following code works well.
QRegularExpression re3("\\");
QRegularExpressionMatch mat = re3.match(tst);But I tried with :
QString pattern("^=?[a-z1-9A-Z\s+-*/]*");
QRegExp rx(pattern);
bool match = rx.exactMatch(tst);
then it works well.Anybody know the reason?
Thanks
-
Hi,
Your first star is the problem.
What exactly are you trying to search ?
-
should be this expression, don't know why when I posted it, browser seems removed some backslashes -
Still your first * is the problem. Hence my question, what do you want to extract exactly with your expression ?
-
I want to match the following string:
Number, 1 2 3 ..
and A1 b3 C3 ..M19 ..
formula: =A1+B1 / c3 ... -
@SGaist then how can I put a Arithmetic operator * in the expression?
-
^=?[a-z1-9A-Z\s*/+-]*
You can use the regular expression tool from Qt's example to test your regular expressions with Qt.
-
It's the \ escaped character reason.