Posted By

world_eggplant on 01/14/10


Tagged

regex email javascript jquery address


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


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


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.

Expand | Embed | Plain Text
  1. function extractEmails ( text ){
  2. return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
  3. }
  4.  
  5. // EXAMPLE #1
  6. var emails = extractEmails ( HugeListWithBulkTextIncludingEmailAddresses );
  7. document.write ( emails.join('\n') );
  8.  
  9.  
  10. // EXAMPLE #2 (jQuery)
  11. $(function(){
  12. $('#eform').submit(function(){
  13. $('#extractedemails').val( extractEmails($('#input').val() ).join('\n'));
  14. return false;
  15. });
  16. });

Report this snippet 

You need to login to post a comment.