不限制IP的范围,只要是4组1-3位的数字就匹配上。
\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}
\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}
\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
我这样写的都匹配上不,求帮忙
1、/([0,1]?\d{1,2}|2([0-4][0-9]|5[0-5]))(.([0,1]?\d{1,2}|2([0-4][0-9]|5[0-5]))){3}/
2、^(?:(?:1[0-9][0-9].)|(?:2[0-4][0-9].)|(?:25[0-5].)|(?:[1-9][0-9].)|(?:[0-9].)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$
3.参考一下:http://c.biancheng.net/cpp/html/1437.html
((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))