我想检查单元格中是否有一个单词而不是另一个单词。在这个帖子 https://stackoverflow.com/questions/28775466/google-sheet-regexreplace-match-everything-except-a-particular-pattern关于这个问题有一些讨论,但选定的解决方案包括一个脚本函数。必须有一种更简单的方法来做到这一点。
我想检查字符串“investimentos”中是否存在字符串“investimentos”而“fundos”不存在。
我已经尝试过以下这些(免责声明:我是正则表达式的初学者):
=regexmatch("investimentos";"(investimentos)^(fundos)")
=regexmatch("investimentos";"(investimentos).*^(fundos)")
=regexmatch("investimentos";"(investimentos)(^fundos)")
=regexmatch("investimentos";"(investimentos).*(^fundos)")
我总是变得虚伪。这是为什么?
没有环视支持RE2 https://github.com/google/re2/wiki/Syntax,所以你不能使用通用逻辑匹配一个字符串,排除另一个字符串 https://stackoverflow.com/questions/2953039/regular-expression-for-a-string-containing-one-word-but-not-another.
如果负值只有 1 个字符,则可以使用单个正则表达式来完成此操作。喜欢^[^I]*GO[^I]*$
将匹配没有的字符串I
但包含GO
,但如果您要排除的单词中有多个字符,则它将不起作用。
Use
=AND(REGEXMATCH(A1;"investimentos");NOT(REGEXMATCH(A1;"fundos")))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)