/**
* 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
function validateEmail($email) {
var emailReg = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/;
return emailReg.test( $email );
}
if( !validateEmail(emailaddress)) { /* do stuff here */ }
var emailRegex = /^[-!#$%&'*+/0-9=?A-Z^_a-z{|}~](.?[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*.?[a-zA-Z0-9])*.[a-zA-Z](-?[a-zA-Z0-9])+$/;
function isEmailValid(email) {
if (!email)
return false;
if(email.length>254)
return false;
var valid = emailRegex.test(email);
if(!valid)
return false;
// Further checking of some things regex can't handle
var parts = email.split("@");
if(parts[0].length>64)
return false;
var domainParts = parts[1].split(".");
if(domainParts.some(function(part) { return part.length>63; }))
return false;
return true;
}
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