如何从文本中解析/修剪电子邮件地址 [英] How to parse/trim email addresses from text
问题描述
类似于此问题,但不是
可信用户(不需要关心验证输入)正在将文本字段中输入/粘贴电子邮件地址。在模糊事件中,我想查看文本并清理所输入的内容(通常在复制和粘贴电子邮件客户端的地址列表后)。
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屋!