Reputation: 2357
I have this regex for URL validation and it works fine but it doesn't pass if URL contains hyphen
like www.i-card.com
, this is a valid domain, it should pass it. Here is my regex:
^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?[a-zA-Z0-9#]+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?$
Upvotes: 1
Views: 1063
Reputation: 4162
Try this version:
^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9\-]+(\.[a-z\-]{2,}){1,3}(#?\/?[a-zA-Z0-9\-#]+)*\/?(\?[a-zA-Z0-9-_\-]+=[a-zA-Z0-9-%\-]+&?)?$
Upvotes: 3