所以我试图验证一个包含第一个文本的字符串,然后是一个包含斜角括号的电子邮件'<>',例如
'Test <postmaster@email.academy>'
我一直试图解决这个问题很长一段时间,我想知道是否有一个正则表达式可以帮助我验证电子邮件总是被斜角括号
var data = {
from: 'Test <postmaster@email.com>',
};
var dataValidation = function (data){
var fromEmailAddress = data.from.split(' '); //['Test','<postmaster@email.com>']
/////code below doesn't work as I have angled brackets around the email
var validEmail = /^[A-Za-z0-9._%+-]+@([A-Za-z0-9-]+.)+([A-Za-z0-9]{2,4}|museum)$/;
if(validEmail.test(fromEmailAddress[1])){
console.log(fromEmailAddress[1])
}
};