I have the following regex which works fine with online validators (https://regex101.com/r/d56Jmg/1). It is for validating floating point numbers which have a maximum number of 9 digits.
^[-+]?(?!0d)(?!(?:[.,]?d){10,})d*[.,]?d+
When I use it with QRegularExpressionValidator it always returns Intermediate state. Even for strings which have more than 9 digits.
Can anyone explain that behaviour and maybe even suggest a solution?
Here is an example code for c++
QString regex = ^[-+]?(?!0\d)(?!(?:[.,]?\d){10,})\d*[.,]?\d+
auto regex_validator = new QRegularExpressionValidator(QRegularExpression(regex));
QString test("0.123456789");
QString test2("+0.1234567");
int pos = 0;
auto test_ok = regex_validator->validate(test, pos);
auto test2_ok = regex_validator->validate(test2, pos);
Both test_ok
and test2_ok
are Intermediate. I need test_ok
to be Invalid.