QRegExp
-
Please help !!! I'm trying this code for regular expressions,but it always returns false...Any idea ?? Thank You !!
@if (user.contains(QRegExp("/^[a-z0-9]$/")))
{
QMessageBox::information (this, "Validation", "Valide !");}
else{ QMessageBox::warning(this, "Kujdes", "Te dhenat tuaja jane te pasakta.\n Riprovo perseri."); }
}@
-
Hi,
Please don't multi-post on the forum.
What is your input and what are trying to find ?
-
I'm sorry about the multi-post.it was accidentally.
I'm trying to make a check if a user inputs for example characters like !@#$%^ ..it should input just characters and numbers..not other characters..what should I do ?
Thank You -
First, have a look at the QRegExp doc, they provide nice examples
Also note that your test is wrong: your string should be invalid if it contains something else than a-z0-9. In other words: you must search for what it should not contain.
-
Why do you have these two / ?
Without them your regexp mean: Start of line, one lower case letter or a number, end of line. Not really what you want.
You can test and validate your regexp with the regexp example in qt_sources/examples/tools/regexp
-
If you want to constrain your user's input, have a look at "QRexExpValidator":http://qt-project.org/doc/qt-4.8/qregexpvalidator.html