Javascript 判断字符串是否是IP地址。
文章源自陈学虎-https://chenxuehu.com/article/2018/10/7303.html
function isIp(ipstr) { try { if(ipstr=="" || ipstr==undefined)return false; if(!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/.test(ipstr)) { return false; } var ls=ipstr.split('.'); if(ls==null || ls.length!=4 || ls[3]=="0" || parseInt(ls[3])===0) { return false; } return true; }catch(ee){} return false; }
文章源自陈学虎-https://chenxuehu.com/article/2018/10/7303.html 文章源自陈学虎-https://chenxuehu.com/article/2018/10/7303.html
评论