如何使用Regex& amp;验证域名?? [英] How to validate a domain name using Regex & Php?
本文介绍了如何使用Regex& amp;验证域名??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个仅验证域名而不验证完整URL的解决方案,下面的示例是我要寻找的内容:
I want a solution to validate only domain names not full urls, The following example is what i'm looking for:
domain.com -> true
domain.net -> true
domain.org -> true
domain.biz -> true
domain.co.uk -> true
sub.domain.com -> true
domain.com/folder -> false
domµ*$ain.com -> false
推荐答案
怎么样:
^(?:[-A-Za-z0-9]+\.)+[A-Za-z]{2,6}$
这篇关于如何使用Regex& amp;验证域名??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文