regexqtqregexp

Regular expression for double values using QRegExp


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.


Solution

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

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