I need a PHP RegEx that allow "a-z" & "A-Z" & "-" & "."
- "." is allow to use minimum 1 and maximum 2 times and not together ".."
- "-" may use many times but not together "--" and cannot use after last dot "."
in other words I want to validate domain or sub-domain name like:
my-domain.com or sub.my-domain.com
and for eg: my--domain.com or my-domain.com-net or my-domain-.com or etc must return false.
if (!preg_match('/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/', $odomain)) {
//do something
}