我的电子邮件入口格式像username@domain.extension一样
用户名以英文字母字符开头,随后的任何字符都由以下一个或多个字符组成:字母数字字符,-,。,_. .
域和扩展名只包含英文字母。扩展长度为1,2或3个字符。
我使用下面的regex验证我的电子邮件地址:
[a-zA-Z]+\s<\b[a-z0-9._-]+@[a-zA-Z]+\.[A-Za-z]{1,3}\b>
电子邮件地址:
this <is@valid.com>
this <is_it@valid.com>
this <_is@notvalid.com>
我需要验证域名注册,因为它不能只由数字和验证需要适合我的算法工作的方式,即返回完整的域名(没有.com,.net等扩展名),如果它是正确的。
我尝试了几个表达式,但都没有成功:
^[^0-9]+$ # that one wont let he type a number
^\w[^0-9]+\w$ # that wont work too
有人能帮我吗?
如何检查url是否是ip地址而不是域名? 例如: http://www.yeouuuuu.com/bla
https://www.bbc.co.uk/something
http://yeou:password@my.service.com/
//return true;
http://172.10.10.100/test
//return false; because there is an IP. ip4正则表达式: ipv4 = RegExp('((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|
[0-9])\\.){3}(25[0-
if (isValidDomainName(addr)) {
return true;
}
else if (isValidIPv4(addr)) {
return true;
}
function isValidIPv4(addr){
var regex = /^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])$/;
return regex.test(addr);
}
function isValidDomainName(name