日期:2014-05-16 浏览次数:20414 次
var str = '92.168.0.2,192.168.0.3,192.168.0.4'; var pattern = /^((\d{1,3}\.)){3}\d{1,3}(,((\d{1,3}\.)){3}\d{1,3})*$/g; //规则没有太细 var re = pattern.test(str); alert(re);
------解决方案--------------------
<script>
var ips = "192.168.0.2,192.168.0.3,192.168.0.4";
var rul = /^\d{1,3}(\.\d{1,3}){3,3}(,\d{1,3}(\.\d{1,3}){3,3})*$/;
if(!rul.test(ips)){
alert("不是完全的ip组结构");
}
</script>
------解决方案--------------------
var str = '92.168.0.2, 192.168.0.3, 192.168.0.4', pattern = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\,?\s*)*$/;
alert(pattern.test(str));
------解决方案--------------------
var ip="192.123.43.23,192.123.32.12,123,123,32,43,"; var regexq=/^([0-2][0-9][0-9]\.[0-2][0-9][0-9]\.[0-2]*[0-9]*[0-9]\.([0-2]*[0-9]*[0-9])).+[^\,]$/g; alert(regexq.test(ip));