Have you tried to check the strings with a regular expression? See QRegularExpression.