Implement a regex in QRegExp
Here is the regex and how i use it.
Code:
"^(?: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+)$";
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
Re: Implement a regex in QRegExp
For a start your regular expression is broken and your compiler is probably warning you about an unknown escape "\.". You need to double-up the \\ before the periods in the domain name and ip address.
Once you have that fixed, your domain name would have to be all upper-case.
Re: Implement a regex in QRegExp
Quote:
Originally Posted by
ChrisW67
For a start your regular expression is broken and your compiler is probably warning you about an unknown escape "\.". You need to double-up the \\ before the periods in the domain name and ip address.
Once you have that fixed, your domain name would have to be all upper-case.
Actually no, the compiler didn't warn me about unknown escape, beside that i did try also double slash \\. but no didn't work.
As you said i tried to make domain In upper-case, but the results was same !
And something else can somehow make that regex case-insensitive by the QRexExp itself?
Update:
Yes you were right, i just:
and make it CaseInsensitive :D, and now it works. i should test it more.
Thanks ChrisW67