在 Google Sheet 中检测一个字符串,并根据结果输出不同的字符串

Detect a string in Google Sheet and output a different string based on the result

我使用 REGEXMATCH 检测 sheet 中的字符串。我需要用文本替换单元格值。

例如检测"One"输出"Text one",检测"Two"输出"A second text",检测"three"输出"Another text"。 *

我已经在用了:

=IF(OR(REGEXMATCH('Sheet'!A2;"One");REGEXMATCH('Sheet'!A2;"Two"));"Texte 1";"My second text")

但这只是基于TRUE/FALSE,我最多有4种可能。

你可以用替代品来做到这一点。您可能需要将我的“,”替换为“;”语言差异

=substitute(substitute(substitute(SUBSTITUTE(A2,"One","Teste 1"),"Two","My second text"),"Three","My third text"),"Four", "My fourth text")

IFS允许更多条件:

=IFS(REGEXMATCH(A1,"One"),1,REGEXMATCH(A1,"Two"),2, ...)