Oh boy, what I was trying to tell you was:
QRegExp rx
("^([a-zA-Z]+([-a-zA-Z0-9]|\\.[-a-zA-Z0-9]+)*|[a-zA-Z]{1})$");
QStringList teststrings
= QString("2test -test .test test test2 testX test. test-.-. t test..t te.s.t t.es-t tes--t t2est te3443st").
split(" ");
for (int i = 0; i < teststrings.count(); ++i)
qWarning() << teststrings.at(i) << rx.exactMatch(teststrings.at(i));
QRegExp rx("^([a-zA-Z]+([-a-zA-Z0-9]|\\.[-a-zA-Z0-9]+)*|[a-zA-Z]{1})$");
QStringList teststrings = QString("2test -test .test test test2 testX test. test-.-. t test..t te.s.t t.es-t tes--t t2est te3443st").split(" ");
for (int i = 0; i < teststrings.count(); ++i)
qWarning() << teststrings.at(i) << rx.exactMatch(teststrings.at(i));
To copy to clipboard, switch view to plain text mode
"2test" false
"-test" false
".test" false
"test" true
"test2" true
"testX" true
"test." false
"test-.-." false
"t" true
"test..t" false
"te.s.t" true
"t.es-t" true
"tes--t" true
"t2est" true
"te3443st" true
...or even more easier:
QRegExp rx
("^[a-zA-Z]+([-a-zA-Z0-9]|\\.[-a-zA-Z0-9]+)*$");
QRegExp rx("^[a-zA-Z]+([-a-zA-Z0-9]|\\.[-a-zA-Z0-9]+)*$");
To copy to clipboard, switch view to plain text mode
Bookmarks