abu*_*nte 1 regex google-sheets re2
我想检查一个单元格中是否有一个单词,但没有另一个。在这篇文章中,对此事有些热议,但是当选的解决方案包括一个脚本功能。必须有一种更简单的方法来做到这一点。
我想检查字符串“ investimentos”中是否存在字符串“ investimentos”而没有“ fundos”。
我已经尝试过以下方法:(免责声明:我是regex的初学者)
=regexmatch("investimentos";"(investimentos)^(fundos)")
=regexmatch("investimentos";"(investimentos).*^(fundos)")
=regexmatch("investimentos";"(investimentos)(^fundos)")
=regexmatch("investimentos";"(investimentos).*(^fundos)")
Run Code Online (Sandbox Code Playgroud)
我总是假的。有人可以在里面发光吗?
RE2不支持环视,因此您不能使用通用逻辑来匹配一个字符串,但不包括另一个字符串。
如果取反值仅是1个字符,则可以使用单个正则表达式来实现。Like ^[^I]*GO[^I]*$将匹配一个不I包含但包含的字符串GO,但是如果要排除的单词中包含多个字符,它将无法正常工作。
使用
=AND(REGEXMATCH(A1;"investimentos");NOT(REGEXMATCH(A1;"fundos")))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
651 次 |
| 最近记录: |