使用JavaScript从文本文件中提取电子邮件地址 [英] Extract email addresses from a text file using JavaScript

查看:146
本文介绍了使用JavaScript从文本文件中提取电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有超过2000个电子邮件地址。我从feedburner出口。
和电子邮件地址如下所示;

I have more than 2000 email addresses. which i have exported from feedburner. And the email address look like below;

    adminvicky@gmail.com   Active  12/05/2015  03:07
   adminvishal250@gmail.com   Pending Verification 8/05/2015  01:07

我想要通过删除活动,待定验证,日期[即,从文本文件中提取电子邮件地址] [05/02/2015]和时间[即03:07]使用JavaScript。

I want to extract email address from the text file by removing Active, Pending Verification, Date [i.e. 8/05/2015] and time [i.e 03:07] using JavaScript.

我创建了一个类似于下面的JavaScript程序,它可以正常工作以删除Active,Pending验证文字,

I have created a JavaScript Program which something like below which working properly for removing Active, Pending verification text,

<script>
  function extracter() {

    var a = document.getElementById('input').value;

    document.getElementById('output').innerHTML =

    a.replace(/Active|Pending|Verification| /g, '');

  }
</script>

<textarea id="input"></textarea><br/>
<br/>

<input type="button" value="click" onclick="extracter()"/>
<br/>
<br/>
<textarea id="output"></textarea>

输出为,

 adminvicky@gmail.com  12/05/2015  03:07
   adminvishal250@gmail.com  8/05/2015  01:07

我想要以下输出。只需帮我删除日期时间

And I want the below output. Just help me to remove "Date" and "Time",

     adminvicky@gmail.com 
   adminvishal250@gmail.com


推荐答案

尝试这个,我认为它会完成这项工作

Try this one, i think it will do the job

var a = document.getElementById('input').value;

document.getElementById('output').innerHTML = extractEmails(a).join('\n');

功能:

function extractEmails (text)
{
    return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
}

这是小提琴

这里也是一个使用jQuery的例子使用jquery从批量文本中提取所有电子邮件地址

Here is also an example using jQuery also Extract all email addresses from bulk text using jquery

这篇关于使用JavaScript从文本文件中提取电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆