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
/
^((([a-z0-9][a-z0-9\-]*[a-z0-9])|[a-z0-9]+)\.)*([a-z]+|xn\-\-[a-z0-9]+)\.?$
/
Unit Tests
dicas-l.com.br
→ regex does match
911.gov
→ regex does match
911
→ regex does not match
a-.com
→ regex does not match
-a.com
→ regex does not match
a.com
→ regex does match
a.66
→ regex does not match
exemplo.xn--6frz82g
→ regex does match
ople.xn--6qq986b3xl.
→ regex does match
my_host.com
→ regex does not match
typical-hostname33.whatever.co.uk
→ regex does match