Regular expression for double values using QRegExp

Eduard Rostomyan picture Eduard Rostomyan · Mar 31, 2014 · Viewed 15.5k times · Source

I am writing a regular expression checker for QLineEdit and I am using QRegExp.

I have already wrote a int value checker:

QRegExp *expression_ = new QRegExp("^(0|[1-9]{1,1}[0-9]{0,9});

But I have complications with double values, to be more specific, I cannot separate the case of this numbers. F.E 0.210 or 0.001.

Please help me to implement this feature for double values. Thanks in advance.

Answer

Bowdzone picture Bowdzone · Mar 31, 2014

This is what I'm using as a RegEx String for positive/negative float values

[+-]?\\d*\\.?\\d+