Yet another URL prefix regex question (to be used in C#).
Posted
by Hamish Grubijan
on Stack Overflow
See other posts from Stack Overflow
or by Hamish Grubijan
Published on 2010-05-06T14:23:59Z
Indexed on
2010/05/06
14:28 UTC
Read the original article
Hit count: 151
Hi, I have seen many regular expressions for Url validation. In my case I want the Url to be simpler, so the regex should be tighter:
Valid Url prefixes look like:
- http[s]://[www.]addressOrIp[.something]/PageName.aspx[?]
This describe a prefix. I will be appending ?x=a&y=b&z=c
later. I just want to check if the web page is live before accessing it, but even before that I want to make sure that it is properly configured. I want to treat bad url
and host is down
conditions differently, although when in doubt, I'd rather give a host is down
message, because that is an ultimate test anyway. Hopefully that makes sense. I guess what I am trying to say - the regex does not need be too aggressive, I just want it to cover say 95% of the cases.
This is C# - centric, so Perl regex extensions are not helpful to me; let's stick to the lowest common denominator.
Thanks!
© Stack Overflow or respective owner