[英]Regex to match multiple emails separated by space or puncts
I need a regex to match multiple email address separated by space(s) and/or puncts. 我需要一个正则表达式来匹配多个用空格和/或点分隔的电子邮件地址。 The email addresses are into a string. 电子邮件地址是一个字符串。 I'm trying this, but it doesn't works 我正在尝试这个,但是没有用
^(\s[[:punct:]])*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}){1}(\s[[:punct:]])*$
Text could be like this: 文字可能是这样的:
abcd@abcd.ef, abcd@abcd.ef abcd@abcd.ef abcd @ abcd.ef,abcd @ abcd.ef abcd@abcd.ef
Or even like this 甚至像这样
Lorem ipsum dolor sit abcd@abcd.ef amet, consectetur, abcd@abcd.ef, adipiscing elit. Lorem ipsum dolor坐abcd@abcd.ef amet,安全,abcd@abcd.ef,忠实拥护。 Vestibulum consectetur fringilla mi ac dignissim. Vestibulum consectetur fringilla mi ac dignissim。 Nulla at est quam. Nulla在est quam。 abcd@abcd.ef Sed enim. abcd@abcd.ef Sed enim。
you could replace the ^ and $ anchors with something that doesn't force the email to be both first and last in the line... 您可以将^和$锚替换为不强制电子邮件同时排在第一行和最后一行的内容...
like \\b (word boundry) 像\\ b(字边界)
\b(\s[[:punct:]])*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}){1}(\s[[:punct:]])*\b
or nothing at all ? 还是什么都没有?
(\s[[:punct:]])*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}){1}(\s[[:punct:]])*
http://rubular.com/r/AMnr2kzp09 http://rubular.com/r/AMnr2kzp09
or simply 或简单地
(\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,6}\b)
since the {1} was restricting the number of emails you could match between ^ and $ 由于{1}限制了您可以在^和$之间匹配的电子邮件数量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.