Getting Litterals ., + and - in a QRegExp
-
I have this humongous regular expression to express any positive integer or real number (I tested it on http://regexr.com/):
^\+?((0*[1-9][0-9]*(\.[0-9]+)?((e|E)?[\+|\-]?[1-9][0-9]*)?)|([0-9]+\.[0-9]*[1-9][0-9]*((e|E)?(\+|\-)?[0-9]*[1-9][0-9]*)?))$My question is: how do I make this into a valid QRegExp? Using it as above is not accepted as Qt complains that ., + and - are not recognized as valid escape sequences...
-
Hi,
Are you locked to QRegExp ? It has been deprecated. QRegularExpression would be more suited.
As for your question, you need to escape them using two backslashes.
"^\\+?((0*[1-9][0-9]*(\\.[0-9]+)?((e|E)?[\\+|\\-]?[1-9][0-9]*)?)|([0-9]+\\.[0-9]*[1-9][0-9]*((e|E)?(\\+|\\-)?[0-9]*[1-9][0-9]*)?))$" -
Do you mean the QRegularExpressionValidator ?