Is valid IP address - Node.js Regular expression

Node.js examples for Regular expression:IP Address

Description

Is valid IP address

Demo Code


var isValidIP = function(str){
    var reg = new RegExp(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
    if(typeof str === 'string') return reg.test(str);
    return reg.test(str.toString());
};

Related Tutorials