/ Published in: JavaScript

Easily grabs email addresses from a bulk text (CSV and/or some other email address-filled list/db).
Example #2 takes the input (bulk text) from textarea #input and puts the clean emails in the textarea #extractedemails.
Example #2 takes the input (bulk text) from textarea #input and puts the clean emails in the textarea #extractedemails.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function extractEmails ( text ){ return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi); } // EXAMPLE #1 var emails = extractEmails ( HugeListWithBulkTextIncludingEmailAddresses ); document.write ( emails.join('\n') ); // EXAMPLE #2 (jQuery) $(function(){ $('#eform').submit(function(){ $('#extractedemails').val( extractEmails($('#input').val() ).join('\n')); return false; }); });
Comments
