如何从文本中解析/修剪电子邮件地址 [英] How to parse/trim email addresses from text

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

问题描述

类似于此问题,但不是



可信用户(不需要关心验证输入)正在将文本字段中输入/粘贴电子邮件地址。在模糊事件中,我想查看文本并清理所输入的内容(通常在复制和粘贴电子邮件客户端的地址列表后)。



Bob Smith< bob@company.com> joe@company.com,John Doe< john@company.com>



将被修剪为:



bob@company.com,joe@company.com,john @ company.com

解决方案

  myEmailList = userInput.match /[a-zA-z0-9_.]+@[a-zA-Z0-9_.]+\.(com|org|whatever)/g); 
myEmailListString = myEmailList.join(',');

或者如果你想要一个电子邮件地址的数组,请做第一行。 >

Similar to this question, but not sure how to implement in this case.

A trusted user (don't need to be concerned with validating input) is typing/pasting email addresses into a text field. On the blur event, I'd like to look at the text and clean up whatever he inputed (typically after copying and pasting a list of addresses from an email client).

"Bob Smith" <bob@company.com>, joe@company.com, "John Doe"<john@company.com>

would be trimmed to:

bob@company.com, joe@company.com, john@company.com

解决方案

myEmailList=userInput.match(/[a-zA-z0-9_.]+@[a-zA-Z0-9_.]+\.(com|org|whatever)/g);
myEmailListString=myEmailList.join(', ');

Or just do the first line if you're wanting an array of the email addresses.

这篇关于如何从文本中解析/修剪电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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