Reputation: 738
QRegExp regexpsplineedit("[a-zA-Z0-9\\_\\[\\]\\(\\)]{20}");
qlineedit->setValidator(new QRegExpValidator(regexpsplineedit,this));
This work.
And this not :
if(clipboardtext.contains(QRegExp("[a-zA-Z0-9\\_\\[\\]\\(\\)]{20}")))
But this yes :
if(clipboardtext.contains(QRegExp("[a-zA-Z0-9\\_\\[\\]\\(\\)]")) && clipboardtext.length() <= 20)
Why this happens with same text for input?
Upvotes: 0
Views: 53
Reputation: 19395
Are you validating the length of the string is less than or equal to 20? Or that at least 1 char from that class exists and the total length is less than or equal to 20? That is 2 separate validation steps. Otherwise, its just ^[chars]{1,20}$
– sln
Upvotes: 1