从这些字符串中提取名称和电子邮件的正则表达式是什么?用正则表达式提取电子邮件和名称
[email protected]
John <[email protected]>
John Doe <[email protected]>
"John Doe" <[email protected]>
可以假定电子邮件是有效的。该名称将由电子邮件分隔一个空格,并可能被引用。
预期的结果是:
[email protected]
Name: nil
Email: [email protected]
John <[email protected]>
Name: John
Email: [email protected]
John Doe <[email protected]>
Name: John Doe
Email: [email protected]
"John Doe" <[email protected]>
Name: John Doe
Email: [email protected]
这是我迄今取得的进展:
(("?(.*)"?)\s)?(<?(.*@.*)>?)
(可以在这里进行测试:http://regexr.com/?337i5)
有效电子邮件的所有possiblities您有什么?请注意,用于验证所有电子邮件的正则表达式可能很大。您需要澄清所有电子邮件是否被认为是正确的。 –
我不需要验证电子邮件。 – hpique
您的链接无法使用。 –