Validate URL using regex - Node.js Regular expression

Node.js examples for Regular expression:Validation

Description

Validate URL using regex

Demo Code

Validator.validateUrl = function(url) {
    var exp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
    if (url.match(exp)) {
        return true;
    } else {/*from  w ww  .j av a2  s .co  m*/
        return false;
    }
};

Related Tutorials