> 文档中心 > pyhon中校验域名的正则表达式

pyhon中校验域名的正则表达式

1. Check whether a string looks like a valid domain name(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$# 普通校验中一个更严谨的校验方式^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$ 2. Find valid domain names in longer text(?i)\b([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b 3. Check whether each part of the domain is not longer than 63 characters(?i)\b((?=[a-z0-9-]{1,63}\.)[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b 4. Allow internationalized domain names using the punycode notation(?i)\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b 5. Check whetehr each part of the domain is not longer than 63 characters, and allowinternationalized domain names using the punycode notation(?i)\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b