PDA

View Full Version : QRegExp validator



mattia
28th November 2007, 08:08
Hi, i'd like to create a QRegExp to validate my input, i need a regExp that allows the user to insert digit, letters and space, but the first chat can't be a space.
I created this one:
"[A-Za-z0-9\\s]+"
but as you can see i can insert a space and the validator is true, and it's not good...what should i do?
thx

mattia
28th November 2007, 08:13
something like taht works:
"^[A-Za-z0-9]+[A-Za-z0-9\\s]+"
is there a better way?

wysota
28th November 2007, 08:15
"[A-Za-z\\d][A-Za-z\\d\\s]*" should do the trick.