Here is the regex and how i use it.
"^(?:http|ftp)s?://" // http:// or https://
"(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|" // #domain...
"localhost|" // localhost...
"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})" // ...or ip
"(?::\\d+)?" // optional port
"(?:/?|[/?]\\S+)$";
QString regexPattern =
"^(?:http|ftp)s?://" // http:// or https://
"(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|" // #domain...
"localhost|" // localhost...
"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})" // ...or ip
"(?::\\d+)?" // optional port
"(?:/?|[/?]\\S+)$";
_regexValidator = new QRegExpValidator(QRegExp(regexPattern), this->parent());
To copy to clipboard, switch view to plain text mode
Problem is that the QRegExpValidator::validate() never returns Acceptable.
I don't know what part i missing in it.
Also the regex is for URL validation ;)
For the record, the regular experssion itself is stolen from django.core.validators.URLValidator
Bookmarks