Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
\(?(?:(http|https):\/\/)(?:((?:[^\W\s]|\.|-|[:]{1})+)@{1})?((?:www.)?(?:[^\W\s]|\.|-)+[\.][^\W\s]{2,4}|localhost(?=\/)|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?::(\d*))?([\/]?[^\s\?]*[\/]{1})*(?:\/?([^\s\n\?\[\]\{\}\#]*(?:(?=\.)){1}|[^\s\n\?\[\]\{\}\.\#]*)?([\.]{1}[^\s\?\#]*)?)?(?:\?{1}([^\s\n\#\[\]]*))?([\#][^\s\n]*)?\)?
/
Unit Tests
http://net.tutsplus.com/about
→ regex does match
http://google.com
→ regex does match
http://google
→ regex does not match
www.google.com
→ regex does not match
http://foo.com/blah_blah
→ regex does match
http://foo.com/blah_blah_(wikipedia)
→ regex does match
http://foo.com/blah_blah_(wikipedia)_(ag…
→ regex does match
http://www.example.com/wpstyle/?p=364
→ regex does match
https://www.example.com/foo/?bar=baz&ing…
→ regex does match
asdf
http://google.com
→ regex does match
http://io9.com
→ regex does match
http://foo.com/blah_(wikipedia)#cite-1
→ regex does match
http://code.google.com/events/#&product=…
→ regex does match
http://-error-.invalid/
→ regex does not match
ftp://google.com
→ regex does not match