Validate URL with or without protocol

Hi I would like to validate this following urls, so they all would pass with or without http/www part in them as long as there is TLD present like .com, .net, .org etc..

Valid URLs Should Be:

http://www.domain.com

http://domain.com

www.domain.com
domain.com

Also maybe allow even IPs:

127.127.127.127

(but this is extra!)

Also allow dashes (-), forgot to mantion that =)

I’ve found many functions that validate one or another but not both at same time.
If any one knows good regex for it, please share. Thank you for your help.

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories