电子邮件正则表达式返回空

Email regex returning empty

我正在尝试使用 Zapier 代码中的正则表达式从一串文本中提取多个电子邮件地址。

var rawList = "This is just a test of everything@test.com not sure how regex@email.com can extract multiple email@addresses.com but we will see";

var emailList = rawList.match(/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/);

console.log(emailList)

这总是 returns emailList 为空。我从 https://www.regular-expressions.info/index.html 中提取了这个正则表达式我也尝试过来自其他网站的电子邮件正则表达式,但仍然有相同的经历。

我还使用了 Zapier 的 Formatter 的 Extract Pattern 选项并尝试了相同的表达式,但也没有成功。不确定这里发生了什么?

您的正则表达式代码无效。你应该使用 /(([A-Za-z0-9]+\w*[\.\-]?){1,}\w*@([A-Za-z0-9]+\.){1,2}[A-z]{2,3})/gm.

参见下面的测试。

var rawList="This is just a test of everything@test.com not sure how regex@email.com can extract multiple email@addresses.com but we will see";
var emailList=rawList.match(/(([A-Za-z0-9]+\w*[\.\-]?){1,}\w*@([A-Za-z0-9]+\.){1,2}[A-z]{2,3})/gm);
console.log(emailList);