Regular expression (host port)

Determine whether the port is qualified

var reg=/^([0-9]|[1-9]\d{
    
    1,3}|[1-5]\d{
    
    4}|6[0-4]\d{
    
    4}|65[0-4]\d{
    
    2}|655[0-2]\d|6553[0-5])$/
if(reg.test(value)==false){
    
    
console.log("端口不合格")
}

Determine whether the host is normal

var reg=/^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){
    
    3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/
if(reg.test(value)==false){
    
    
console.log("主机不合格")
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324353849&siteId=291194637