regex - 如何仅使用公式在 Excel 或 Google Sheets 中获取 2 个不同字符之间的电子邮件地址?

标签 regex google-sheets excel-formula google-sheets-formula array-formulas

单元格 A2 具有以下示例电子邮件地址:

Jose Rizal <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea8085998faa8f878b8386c4898587" rel="noreferrer noopener nofollow">[email protected]</a>>

我只想获取单元格 B2 中的电子邮件地址:

=right(A2,len(A2) - search("<",A2,1))

但结果是: [email protected] >(最后一个字符上有 >)。

表格如下所示,预期结果在 B2 上:

  |            A                |          B         |
 1| complete email address      | email address only |
 2| Jose Rizal <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="610b0e120421040c00080d4f020e0c" rel="noreferrer noopener nofollow">[email protected]</a>> | <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fe94918d9bbe9b939f9792d09d9193" rel="noreferrer noopener nofollow">[email protected]</a>     |

我的配方需要改进什么?

最佳答案

粘贴到B2:

=REGEXEXTRACT(A2, "<(.*)>")

0

数组公式将是:

=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A2:A, "<(.*)>")))

关于regex - 如何仅使用公式在 Excel 或 Google Sheets 中获取 2 个不同字符之间的电子邮件地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58614805/

相关文章:

loops - Excel VBA 中的循环

c++ - regex_match 没有找到任何匹配项

javascript - 如何在javascript中替换任何特定多字符字符串之前的字符串的一部分?

javascript - 如何在 Google 表格中将值舍入为整数的倍数?

google-sheets - 将数据透视表的总计单元格复制到谷歌电子表格中的另一个单元格

excel - 函数的条件分支会引发错误的圆引用错误

excel - TEXTJOIN 输出的逆序

javascript - 电子邮件的正则表达式不起作用

Blogger 中每个 archive.html 的正则表达式自定义重定向

arrays - Google Sheets - 根据相应单元格范围中的数值连接单元格范围中的文本的公式