我正在使用LibreOffice 4.2.8,并且在使用CountIf时我注意到一些不一致的行为。我想知道我是否遗漏了什么。当我可以选择使用正则表达式(工具 - >选项 - > LibreCalc->计算 - >在公式中启用正则表达式)时,在包含一些可控制的字符的行上使用countif时,我得到0正则表达式中的字符。在下表中,将是A1,B1,C1。然而,这些相同的角色本身似乎工作得很好。在下表A,B,C中。当我在公式中转换正则表达式时,这些差异消失了,但我注意到“=”失败了。这是一个错误还是我错过了一些微妙的东西,就像在bash上逃避规则一样?
打开正则表达式
A |B |C (formula in B)
------|----|---------------
One |1 |=COUNTIF(A$3:A3,A3)
Two |1 |=COUNTIF(A$3:A4,A4)
( |1 |=COUNTIF(A$3:A5,A5) <<<<<<<<<<<<< A
] |1 |=COUNTIF(A$3:A6,A6)
[ |1 |=COUNTIF(A$3:A7,A7) <<<<<<<<<<<<< B
One |2 |=COUNTIF(A$3:A8,A8)
Two |2 |=COUNTIF(A$3:A9,A9)
One ( |0 |=COUNTIF(A$3:A10,A10) <<<<<<<<<<<<< A1
Two [ |0 |=COUNTIF(A$3:A11,A11) <<<<<<<<<<<<< B1
One ] |1 |=COUNTIF(A$3:A12,A12)
Two ) |0 |=COUNTIF(A$3:A13,A13)
| |1 |=COUNTIF(A$3:A14,A14) <<<<<<<<<<<<< C
One | |0 |=COUNTIF(A$3:A15,A15) <<<<<<<<<<<<< C1
= |0 |=COUNTIF(A$3:A16,A16)
One = |1 |=COUNTIF(A$3:A17,A17)
+ |1 |=COUNTIF(A$3:A18,A18)
Two + |0 |=COUNTIF(A$3:A19,A19)
^ |1 |=COUNTIF(A$3:A20,A20)
& |1 |=COUNTIF(A$3:A21,A21)
* |1 |=COUNTIF(A$3:A22,A22)
One ^ |0 |=COUNTIF(A$3:A23,A23)
Two & |1 |=COUNTIF(A$3:A24,A24)
One * |2 |=COUNTIF(A$3:A25,A25)
关闭正则表达式
A |B |C (formula in B)
------|------|----------
One |1 |=COUNTIF(A$1:A1,A1)
Two |1 |=COUNTIF(A$1:A2,A2)
( |1 |=COUNTIF(A$1:A3,A3)
] |1 |=COUNTIF(A$1:A4,A4)
[ |1 |=COUNTIF(A$1:A5,A5)
One |2 |=COUNTIF(A$1:A6,A6)
Two |2 |=COUNTIF(A$1:A7,A7)
One ( |1 |=COUNTIF(A$1:A8,A8)
Two [ |1 |=COUNTIF(A$1:A9,A9)
One ] |1 |=COUNTIF(A$1:A10,A10)
Two ) |1 |=COUNTIF(A$1:A11,A11)
| |1 |=COUNTIF(A$1:A12,A12)
One | |1 |=COUNTIF(A$1:A13,A13)
= |0 |=COUNTIF(A$1:A14,A14) <<<<<<<<
One = |1 |=COUNTIF(A$1:A15,A15)
+ |1 |=COUNTIF(A$1:A16,A16)
Two + |1 |=COUNTIF(A$1:A17,A17)
^ |1 |=COUNTIF(A$1:A18,A18)
& |1 |=COUNTIF(A$1:A19,A19)
* |1 |=COUNTIF(A$1:A20,A20)
One ^ |1 |=COUNTIF(A$1:A21,A21)
Two & |1 |=COUNTIF(A$1:A22,A22)
One * |1 |=COUNTIF(A$1:A23,A23)
答案 0 :(得分:0)
对于&#34; =&#34;的问题你可以简单地连接&#34; =&#34;作为COUNTIF
标准中的第一个字符。这意味着只寻找平等:
=COUNTIF(A$3:A3,"="&A3)
这样你也可以计算空单元格。这COUNTIF
通常不会。
对于正则表达式的问题,我知道的唯一方法是SUBSTITUTE
所有可能的危险字符与转义的字符。
=COUNTIF(A$3:A3,"="&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A3,"+","\+"),"|","\|"),"(","\("),")","\)"),"[","\["))
上述公式当然不完全正确。如果完成则会很长。