E-posta listesi filtre

1 Cevap php

I'm not even sure how to ask the question or even how to search for it. I've browsed around and what i've got was some really hardcore regex

Temelde, bu textarea var nerede girdi google bunu nasıl gibi e-posta listemi yapabilirsiniz. Filtre sadece bir çift tırnak içinde bir şey göz ardı etmek mümkün ve sadece

Örnek: "test" <test@test.com>,"test2" <test2@test.com>,"test3" <test@test3.com>

Ben virgül toplayıp e-postaları bölmek mümkün ama aşina değilim < >

Herkes bana yardımcı olabilir? Teşekkürler!

1 Cevap

İşte şipşak versiyonu:

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"]

Anahtarı bu satırı:

 var email = /<(.*?)>/.exec(value)[1];

esas diyor ki:

 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])

Muhtemelen umarım (parantez olmadan) "@", ya da sadece kişiler için ", bob@smith.com," var emin olun, herhangi bir deli giriş için hesap biraz daha karmaşık bir regex yapmak istiyorum, ama olacak Eğer fikir olsun.