如何清除文件中的无效电子邮件地址
我正在寻找一个脚本或可以获取 csv 文件作为输入的东西。 它将逐行解析文件并检查当前行是否包含有效的电子邮件(例如: [电子邮件受保护])
我认为这一定已经存在于某个地方。
带有一些 javascript/jquery 的本地 html 文件将是完美的。
我需要这个来检查手动输入电子邮件且无需验证的列表。
谢谢 米歇尔
I'm looking for a script or something that would get a csv file as imput.
It would parse the file line by line and check if the current line contains a valid email (e.g. : [email protected])
I think this must already exist somewhere.
A local html file with some javascript/jquery would be perfect.
I need this to check lists with manually entered emails with no verification.
Thanks
Michel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你将无法使用 javascript 读取或写入本地文件,我是用 ruby 编写的。如果代码对您没有用,也许正则表达式会对您有用。
You wont be able to read or write local files with javascript, I wrote this in ruby. If the code isn't useful to you maybe the regular expression will.
1) 请注意,验证电子邮件地址非常困难。事实上,想要做到完美是不可能的。这是表达复杂性、覆盖范围和准确性(误报)之间的权衡。请参阅 SO 上有关验证电子邮件地址的无数其他问题,也请参阅此处: http:// /www.regular-expressions.info/email.html
2) 您有一个平面文件 (.csv)。您无法使用 javascript 读取此内容并在浏览器中进行处理。您需要查看其他语言。 Perl 和 Java 随机提及两种语言都有良好的正则表达式支持。
1) Be warned that validating email addresses is extremely hard. In fact it's impossible to do perfectly. It's a trade-off between expression complexity, coverage, and accuracy (false positives). See the zillions of other questions on SO about validating e-mail addresses, and also see here: http://www.regular-expressions.info/email.html
2) You have a flat file (.csv). You can't read this in with javascript and process in a browser. You'll need to look at some other language. Perl and Java to randomly mention two languages have good regex support.
由于您正在寻找 Javascript 解决方案,这里有一些简单的 JS,假设您有一些包含 csv 数据的文件,如下所示:
这是您可能想要替换分隔符、使用的换行符或用于检查地址的正则表达式的脚本。根据您的验证要求,请在此处查找其他正则表达式:在 JavaScript 中验证电子邮件地址?
Since you looked for a Javascript solution, here is some plain JS assuming you have some file containing the csv data like this:
Here is the script where you might want to replace the seperator, the linebreaks used or the regular expression for checking the addresses. Depending on your validation requirements have look for other regular expressions here: Validate email address in JavaScript?
您好,感谢您的回答。
我最终设法使用本地 html 文件和 javascript 来完成它。
方法如下:
为了使其正常工作,我将 csv 文件放在 html 文件旁边,然后使用“输入类型=文件”来加载它
,瞧:-)
原始代码
Hello and thank you for your answers.
I eventually managed to do it with a local html file and javascript.
Here is the method:
In order to have it working, I place the csv file next to the html file, then I use a "input type=file" to load it
And voila :-)
Raw code :