Is valid email by regex - Node.js Regular expression

Node.js examples for Regular expression:Email

Description

Is valid email by regex

Demo Code

    var isValidEmail = function(str){
        var reg = new RegExp(/[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/);
        if(typeof str === 'string') return reg.test(str);
        return reg.test(str.toString());
    };//from  w  w w. j a  v  a2 s  .  c  om
==
Is valid URL by regex
    var isValidUrl = function(str){
        var reg = new RegExp(/^((http)|(https))+:[^\s]+\.[^\s]*$/);
        if(typeof str === 'string') return reg.test(str);
        return reg.test(str.toString());
    };

Related Tutorials