Check if a string is a valid email address - Node.js String

Node.js examples for String:String Value

Description

Check if a string is a valid email address

Demo Code

//check the email
function checkEmail(str) {
    var pattern = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    if (pattern.test(str)) {
        return true;
    } else {//from   ww  w  . jav  a2 s.  c  o m
        return false;
    }
}

Related Tutorials