Domain Name Validation Regular Expression with Recursive Reference

/^

(?P<label>

(?P<letter>[a-z]) |        # One-letter domain name

(?P>letter) (?P<let_dig>[a-z 0-9]) |        # Two-letters domain name

(?P>letter) (?P<ldh_str>[a-z 0-9 \-]){1,61} (?P>let_dig)        # More-letters domain name

)

(\. (?P>label))*?        # More labels

\.?        # Root domain name

$/Dix