/**
* verifie si la chaine renseigné est un email
* check if email is valide
* @param string emailAdress
* @return bool
*/
function isEmail(emailAdress){
let regex = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
if (emailAdress.match(regex))
return true;
else
return false;
}
//see https://regexr.com/3e48o for another exemple
//! check email is valid
function checkEmail(email) {
const re =
/^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
if (re.test(email.value.trim())) {
console.log('email is valid')
} else {
console.log('email is not valid')
}
}
function validateEmail($email) {
var emailReg = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/;
return emailReg.test( $email );
}
if( !validateEmail(emailaddress)) { /* do stuff here */ }
//Expression
let regex = /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/;
let email = "test.gmail.com"
//Execution
if(email.match(regex)){
console.log("valid")
}else{
console.log("Invalid")
}
if(value.match( /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$/gi)){
//code here
}
/^[^s@]+@[^s@]+.[^s@]+$/
var str = "Java Script Object Notation";
var matches = str.match(/(w)/g); // ['J','S','O','N']
var acronym = matches.join(''); // JSON
console.log(acronym)
Run code snippet
let str = "Java Script Object Notation";
let acronym = str.split(/s/).reduce((response,word)=> response+=word.slice(0,1),'')
console.log(acronym);
Run code snippet
var str = "Java Script Object Notation";
var matches = str.match(/(w)/g); // ['J','S','O','N']
var acronym = matches.join(''); // JSON
console.log(acronym)
Run code snippet