Return to Snippet

Revision: 22537
at January 14, 2010 12:47 by world_eggplant


Initial Code
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;
	});
});

Initial URL


Initial Description
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.

Initial Title
Extract email from bulk text (with Regular Expressions, JavaScript & jQuery)

Initial Tags
regex, email, javascript, jquery

Initial Language
JavaScript