How to validate special characters in QString
-
Hi All
I have QStringList<QString> i want to check if any of the QString has special character in it.
how to do this? -
Define "special characters"?
Anyway, I guess QRegExp would come to mind, but you will have to do it per QString. No way do it for the whole QStringList in one go. -
Andre
Special characters like ! @ # $ % ^ & * ( ) _ +
Ya i want to do it per QString only.
-
So... did you look at [[doc:QRegExp]]?
-
HI Andre
I went through it but I m not getting.
I did some thing like this
QRegExp obj[!,@,#,$,%,^,&,*,(,),_,+];
Now I m not getting which function to be used to used?
Please guide. -
Hi
If I do like this
@
QString str = "123345!";
int icount = str.count(QRegExp("!"));
@I get icount as 1;
But I Want to add all special characters in one regular expression and check wether the QString contains anyone of these.How to do this.
-
[quote author="Rajveer" date="1321517103"]Hi
If I do like this
@
QString str = "123345!";
int icount = str.count(QRegExp("!"));
@I get icount as 1;
But I Want to add all special characters in one regular expression and check wether the QString contains anyone of these.How to do this.[/quote]
Try this:
@
QString str = "123345!@#$%^&()_+";
int icount = str.count(QRegExp("[!@#$%^&()_+]"));
@will return 10
-
You are aware that QString supports "unicode":http://unicode.org/?
Are you sure there are no problematic characters in the non-ASCII range of the unicode table?
-
Hi
How to give multiple filter conditions in one regular expression.
Like i wat to filter special characters & alphabets.