1. Check whether a string looks like a valid domain name
(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$
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 allow
internationalized 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
Python 正则表达式验证域名
最新推荐文章于 2023-12-25 19:32:21 发布