Hi! I'm trying to get a RegExp to validate the info of a lineedit which accepts 3 numbers followed by DG and then 4 numbers more and a fifth optional.
For example, valid will be: 123DG1234 or 111DG2222
Invalid ones would be: 111DG or 111DDD or 111 or 111DG222
I have the next but when I try to write, I cant. I doesn't let me write a number or letter or anything. I tried using other RegExp I have for other LineEdits and it works fine so I suppose thta the problem is in the setPattern.
rx9.setPattern("[1-9]\\d{3}][DG]\\d{4,5}");
myLineEdit->setValidator(validator9);
QRegExp rx9;
rx9.setPattern("[1-9]\\d{3}][DG]\\d{4,5}");
QValidator *validator9 = new QRegExpValidator(rx9, this);
myLineEdit->setValidator(validator9);
To copy to clipboard, switch view to plain text mode
EDIT: Andif I put
rx9.setPattern("[1-9]{3}[DG][1-9]{4}");
rx9.setPattern("[1-9]{3}[DG][1-9]{4}");
To copy to clipboard, switch view to plain text mode
It just allows me to write 123D and that's all
Thank you so much
Bookmarks