0

Hey I have tried a regex for valid website url, which is as below

@"(?:[A-Za-z0-9-]+\.)+[A-Za-z0-9]{1,3}:\d{1,5}"

But it didn't work, I tried a lot as well which doesn't work.

I am looking for something which will validate some cases like incomplete url's

like www.yahoo etc., more over it should allow all the domians and it should accept url's starts with http or just www.

Please let me know if there is any work around.

user2486535
  • 418
  • 1
  • 5
  • 20
  • http://www.regxlib.com/ – solidau May 21 '15 at 22:35
  • `/(http|https)\:\/\/(?:(.+?)(?:\:(.+?))?\@)?((?:[\w-]+\.)+)([A-Za-z0-9]+)(?:\:(\d{2,5}))?((?:\/[\w-%.]*)+)?(\?(?:[\w-%&="'+,]+)?)?(\#(?:[^#]+)?)?/` As you can see, supports only http and https protocols, expand it to add more – Downgoat May 22 '15 at 00:36
  • Use https://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx and catch exception. Regex is a poor tool if you don't even bother to read the RFCs for the valid format of a URL. – nhahtdh May 22 '15 at 04:01
  • hey finally fixed my issue by below regex i wrote ^((((h|H)(t|T)(t|T)(p|P)):\/\/){1}|(((h|H)(t|T)(t|T)(p|P)(s|S)):\/\/){1}|(W|w){3}\.)((W|w){3}\.)?([a-zA-Z0-9]+)\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$ – user2486535 May 22 '15 at 20:40

0 Answers0