Php 电子邮件列表过滤器

Php 电子邮件列表过滤器,php,javascript,Php,Javascript,我甚至不知道如何问这个问题,甚至不知道如何寻找它。 我浏览了一下,得到的是一些真正的硬核正则表达式 基本上,我有一个文本区,在这里我可以输入我的电子邮件列表,就像谷歌是如何做到的一样。过滤器应该能够忽略双引号中的任何内容,并且只在 示例:“测试”、“测试2”、“测试3” 我可以通过选择逗号来拆分电子邮件,但不熟悉 有人能帮我吗?谢谢 这里有一个快速版本: var textAreaVal = '"test" <test@test.com>,"test2" <test2@test.

我甚至不知道如何问这个问题,甚至不知道如何寻找它。 我浏览了一下,得到的是一些真正的硬核正则表达式

基本上,我有一个文本区,在这里我可以输入我的电子邮件列表,就像谷歌是如何做到的一样。过滤器应该能够忽略双引号中的任何内容,并且只在<>

示例:
“测试”、“测试2”、“测试3”

我可以通过选择逗号来拆分电子邮件,但不熟悉<>


有人能帮我吗?谢谢

这里有一个快速版本:

var textAreaVal = '"test" <test@test.com>,"test2" <test2@test.com>,"test3" <test@test3.com>';
// Better hope you don't have any "Smith, Bob"-type bits if you do it this way...
var textAreaLines = textAreaVal.split(",");
// Gonna assume you have jQuery here 'cause raw JS loops annoy me ;-)
// (if not you can hopefully still get the idea)
var emails = [];
$$.each(textAreaLines, function(index, value) {
  var email = /<(.*?)>/.exec(value)[1];
  if (email) emails.push(email);
});
// emails =  ["test@test.com", "test2@test.com", "test@test3.com"]
var textAreaVal='“test”、“test2”、“test3”;
//如果你这样做,最好希望你没有任何“史密斯,鲍勃”类型的比特。。。
var textAreaLines=textAreaVal.split(“,”);
//假设这里有jQuery,因为原始JS循环让我很恼火;-)
//(如果不是的话,你仍然有希望得到这个想法)
var=[];
$$。每个(文本区域行、函数(索引、值){
var email=/.exec(value)[1];
如果(电子邮件)电子邮件。推送(电子邮件);
});
//电子邮件=[”test@test.com", "test2@test.com", "test@test3.com"]
关键是这一行:

 var email = /<(.*?)>/.exec(value)[1];
var email=/.exec(value)[1];
基本上说:

 var email =
 // set email to

 /<(.*?)>/
// define a regex that matches the minimal amount possible ("?")
// of any character (".") between a "<" and a ">"

 .exec(value)
 // run that regex against value (ie. a line of input)

 [1];
 // and use only the first matched group ([1])
var电子邮件=
//将电子邮件设置为
//
//定义一个与可能的最小数量(“?”)匹配的正则表达式
//在“”之间的任何字符(“.”)
.exec(值)
//根据值(即输入行)运行该正则表达式
[1];
//并仅使用第一个匹配的组([1])
您可能希望使用稍微复杂一点的正则表达式来解释任何疯狂的输入,确保有一个“@”,或者只为那些这样做的人使用“@”,bob@smith.com,“(没有括号),但希望你能理解