Following up to Regular expression to match hostname or IP Address?
and using Restrictions on valid host names as a reference, what is the most readable, concise way to match/validate a hostname/fqdn (fully qualified domain name) in Python? I’ve answered with my attempt below, improvements welcome.
Following up to Regular expression to match hostname or IP Address? and using Restrictions
Share
ensures that each segment
It also avoids double negatives (
not disallowed), and ifhostnameends in a., that’s OK, too. It will (and should) fail ifhostnameends in more than one dot.