Login Register


Validate URL - [Regex] | [HQ] filter_list
Author
Message
Validate URL - [Regex] | [HQ] #1
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 Smile

Reply

RE: Validate URL - [Regex] | [HQ] #2
That have to be the RegEx with most parameters I've ever seen.
Thanks, though i won't be needing this.
[Image: tumblr_m4vms28lYu1qj3ir1.gif]

Reply

RE: Validate URL - [Regex] | [HQ] #3
damn....whats wrong with Uri.TryCreate() ?
[Image: hObYm.gif]

Reply

RE: Validate URL - [Regex] | [HQ] #4
I'm not great with RegEx, but would this account for URL's such as https://flags.site.com/news.json (just an example).
[Image: CDUAq9d.png]

Reply

RE: Validate URL - [Regex] | [HQ] #5
(08-05-2013, 04:29 PM)loyalty Wrote: damn....whats wrong with Uri.TryCreate() ?

Exactly what I was thinking...

But thanks for the share.

Reply







Users browsing this thread: 1 Guest(s)