![]() |
|
Validate URL - [Regex] | [HQ] - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: Validate URL - [Regex] | [HQ] (/Thread-Validate-URL-Regex-HQ) |
Validate URL - [Regex] | [HQ] - Madara-Uchiha - 08-05-2013 Hey, With this snippet you can validate a URL. PHP Code: Private Sub ValidatewebsiteAddress(ByVal _websiteAddress As String)
If Not Regex.IsMatch(_websiteAddress, _
"^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?") Then
MessageBox.Show("invalid websiteAddress")
Else
MessageBox.Show("valid websiteAddress")
End If
End Sub
I found it in my old sources, I don't own credits, I can't remember where I got this from. Nevertheless its a professional way to validate a URL
RE: Validate URL - [Regex] | [HQ] - Eternity - 08-05-2013 That have to be the RegEx with most parameters I've ever seen. Thanks, though i won't be needing this. RE: Validate URL - [Regex] | [HQ] - loyalty - 08-05-2013 damn....whats wrong with Uri.TryCreate() ? RE: Validate URL - [Regex] | [HQ] - Shebang - 08-05-2013 I'm not great with RegEx, but would this account for URL's such as https://flags.site.com/news.json (just an example). RE: Validate URL - [Regex] | [HQ] - Xanii - 08-08-2013 (08-05-2013, 04:29 PM)loyalty Wrote: damn....whats wrong with Uri.TryCreate() ? Exactly what I was thinking... But thanks for the share. |