使用正则表达式将邮件ID存储到数组中

时间:2016-06-13 06:19:44

标签: javascript regex

我有一个HTML DOM字符串,如下所示

<div><p>Hello,</p> <p>For the following campaign: </p>
<div style="margin-left:50px">
<strong>Account:</strong> BLT+ Digital [ID: 11641] <br>
<strong>Advertiser:</strong> OWN [ID: 23512576] <br> 
<strong>Campaign:</strong> Greenleaf [ID: 43551067]</div>
<p></p> 
<p>...the following creatives have been published to QA and are ready  
for review:</p>
<div style="margin-left:50px"><p>
<strong>Creative:</strong>own_greenleaf_970x250_ROS [ID: 43588775] <br> <strong>Format/Dimensions:</strong> INPAGE[970x250]
<br> <strong>Mode: </strong> HTML5</p></div>
<p><strong>Publisher:</strong> <a>fanaya@bltomato.com</a></p>
<p><strong>CCed:</strong>
<a>drm-support-us@google.com</a>, <a>fanaya.blt@gmail.com</a>
</p>
<p>After QA approves the creatives, if an advertiser association is in place, the creatives can be transferred to the associated advertiser’s creative library.</p> <p>If you're using DoubleClick's QA services, please contact your campaign manager to coordinate the next steps in the QA process.</p>
<p>Custom message:</p><div style="margin-left:50px"><p>
</p></div>
<p>Questions? Visit our help center at <a href="http://www.google.com/support/richmedia/" 
target="_blank">http://www.google.com/support/<wbr>richmedia/</a>.</p> <p>If you still have questions after visiting the help center, or if you believe you received this email in error, please go to <a href="https://support.google.com/richmedia/#contact=1" target="_blank">https://support.google.com/<wbr>richmedia/#contact=1</a>.</p> <p>Regards,<br> The DoubleClick Studio team</p></div>

我必须将邮件ID存储到数组中,如此

var mail_ids = [
'example_id@google.com',
'example_id@gmail.com',
'example_id_another@gmail.com'
];

任何人都可以帮助我使用正则表达式。

1 个答案:

答案 0 :(得分:0)

是你在寻找什么?

$(document).text().match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi)

JSFiddle