javascript - This is how to use regular expressions to verify whether the format of the server address and port number is correct. Please give me some advice!
伊谢尔伦
伊谢尔伦 2017-05-19 10:28:54
0
1
564

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
左手右手慢动作

I didn’t see your regular expression, but I can check it roughly like this

var reg = /^[\d]{1,3}.[\d]{1,3}.[\d]{1,3}.[\d]{1,3}$/;
var regp = /^[\d]+$/;
var s = ['192.168.20.1.1', '192.168.20.1.1.1', '192.168.20.1a', '192.168.20.1', '192.168.20.10000'];
var p = [8080, 0, 333, 'a', '1+'];
for (let i = 0, len = s.length; i < len; i++) {
  console.log('ip', s[i], reg.test(s[i]))
}
for (let i = 0, len = p.length; i < len; i++) {
  console.log('port', p[i], regp.test(p[i]))
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template