电子表格中的 IF 函数参数有问题
Having a problem with IF function argument in Spreadsheet
我正在尝试制作这个描述生成器,但我似乎无法让第一部分像处理其余部分那样处理其中一个 IF 参数。它只检查逻辑表达式,但不会像我在其他 IF 参数中一个接一个地链接那样,将单元格中的其余文本正文与 & 连接起来。这个 example 应该更有意义。
尝试:
=INDEX(REGEXREPLACE(SUBSTITUTE(SUBSTITUTE(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(IFERROR(
SPLIT(B1:B, CHAR(10)))="",,REGEXREPLACE({"", SEQUENCE(1, 100)}&". "&IFNA(VLOOKUP(
TRIM(SPLIT(B1:B, CHAR(10))),
{"ck", "click >";
"box", "select box";
"scd", "scroll down >"}, 2, 0),
SPLIT(B1:B, CHAR(10))), " ", CHAR(13)))),,9^9))),
" ", CHAR(10)), CHAR(13), " "), "^\. !?", ))
demo sheet
第一个 If 语句包含公式的所有其余部分,因此如果正则表达式匹配“ck”,则满足条件,您会得到“点击 >”,但没有其他任何反应。我认为您可以移动最后一个括号,使其位于“select”之后,如下所示:
=IF(REGEXMATCH(B4, "ck"),"click >",IF(REGEXMATCH(B4, "scd"),"scroll down > ",IF(REGEXMATCH(B4, "!"),"","select "))) & ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(TEXTJOIN(CHAR(10), 1, IF(REGEXMATCH(""&
SPLIT(B4, CHAR(10)), "^>.*"),
SPLIT(B4, CHAR(10)), TRANSPOSE(MMULT(TRANSPOSE(TRANSPOSE((SEQUENCE(1, COLUMNS(
SPLIT(B4, CHAR(10))))<=SEQUENCE(COLUMNS(
SPLIT(B4, CHAR(10))), 1, 0))*NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+")))), TRANSPOSE(SIGN(NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+"))))))&". "&
SPLIT(B4, CHAR(10)))), "^0. ", ),"scd",""),"ck",""),"!",""))
我正在尝试制作这个描述生成器,但我似乎无法让第一部分像处理其余部分那样处理其中一个 IF 参数。它只检查逻辑表达式,但不会像我在其他 IF 参数中一个接一个地链接那样,将单元格中的其余文本正文与 & 连接起来。这个 example 应该更有意义。
尝试:
=INDEX(REGEXREPLACE(SUBSTITUTE(SUBSTITUTE(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(IFERROR(
SPLIT(B1:B, CHAR(10)))="",,REGEXREPLACE({"", SEQUENCE(1, 100)}&". "&IFNA(VLOOKUP(
TRIM(SPLIT(B1:B, CHAR(10))),
{"ck", "click >";
"box", "select box";
"scd", "scroll down >"}, 2, 0),
SPLIT(B1:B, CHAR(10))), " ", CHAR(13)))),,9^9))),
" ", CHAR(10)), CHAR(13), " "), "^\. !?", ))
demo sheet
第一个 If 语句包含公式的所有其余部分,因此如果正则表达式匹配“ck”,则满足条件,您会得到“点击 >”,但没有其他任何反应。我认为您可以移动最后一个括号,使其位于“select”之后,如下所示:
=IF(REGEXMATCH(B4, "ck"),"click >",IF(REGEXMATCH(B4, "scd"),"scroll down > ",IF(REGEXMATCH(B4, "!"),"","select "))) & ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(TEXTJOIN(CHAR(10), 1, IF(REGEXMATCH(""&
SPLIT(B4, CHAR(10)), "^>.*"),
SPLIT(B4, CHAR(10)), TRANSPOSE(MMULT(TRANSPOSE(TRANSPOSE((SEQUENCE(1, COLUMNS(
SPLIT(B4, CHAR(10))))<=SEQUENCE(COLUMNS(
SPLIT(B4, CHAR(10))), 1, 0))*NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+")))), TRANSPOSE(SIGN(NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+"))))))&". "&
SPLIT(B4, CHAR(10)))), "^0. ", ),"scd",""),"ck",""),"!",""))