我想比较两段代码并替换与省略号相同的位 - 基本上类似于:
=Regexreplace(A1,JOIN("|",SPLIT(B1,",")),"...")
当我使用这个公式来比较“帮助我,请帮助我”,帮助我,休威泽,帮帮我“,我得到......”,休威泽,......“
但是当我使用它时,比较两个公式(作为文本),比如说:
"=IFERROR(COUNTIF({" & JOIN( "," ,C8:C12) & "},""√ Yes"")/SUM(COUNTIF({" & JOIN( "," ,C8:C12) & "},""√ Yes""),COUNTIF({" & JOIN( "," ,C8:C12) & "},""x No""),COUNTIF({" & JOIN( "," ,C8:C12) & "},""≈ Don't Know"")),0)"
使用:
="=IFERROR(COUNTIF({" & JOIN( "," ,C8:C12) & "},""√ Yes"")/SUM(COUNTIF({" & JOIN( "," ,C8:C12) & "},""√ Yes""),COUNTIF({" & JOIN( "," ,C8:C12) & "},""x No""),COUNTIF({" & JOIN( "," ,C8:C12) & "},""≈ Don't Know"")),0)"
我得到的回报只是第二个公式。
(PS:对于我的工作环境,我使用此代码与关系指针而不是“A1”和“A2”)
=Regexreplace(=INDIRECT("R"&ROW()&"C"&COLUMN()-1,FALSE),JOIN("|",SPLIT(=INDIRECT("R"&ROW()&"C"&COLUMN()-2,FALSE),",")),"...")
答案 0 :(得分:0)
我在正则表达式中发现了you can't use special characters:
有12个特殊含义的字符:
反斜杠
\
,插入符
^
,美元符号
$
,句号或点
.
,垂直条或竖线符号
|
,问号
?
,星号或星号
*
,加号
+
,左括号
(
,右括号
)
,和左方括号
[
,大括号
{
如果要在正则表达式中使用任何这些字符作为文字, 你需要用反斜杠来逃避它们。
在您的情况下,至少有两个:(
,)
逃避特殊字符
为此,请使用以下公式:
=REGEXREPLACE(B2,"(\(|\))","\\$1")
您可以在 regular_expression 中添加更多字符:
(\(|\)|\*|\{|\})
最终的公式是:
=Regexreplace(A2,JOIN("|",SPLIT(REGEXREPLACE(B2,"(\(|\))","\\$1"),",")),"...")