regex for url

match a valid url

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)
abcdef www.whatever.com https://github.com/geongeorge/i-hate-regex https://www.facebook.com/ https://www.google.com/ https://xkcd.com/2293/ https://this-shouldn'[email protected] http://www.example.com/

A valid URL with http/https

This regex validates a url which should include http or https


Cheatsheet

expr usage
/[a-zA-Z0-9]/ matches all lowercase, uppercase letters and numbers
/(hello){4}/ matches "hellohellohellohello"
/^/ matches beginning of a line
/$/ matches end of a line
iHateRegex
by geon