Apache OpenOffice (AOO) Bugzilla – Issue 25654
Wrong results in COUNTIF
Last modified: 2004-02-20 13:30:45 UTC
COUNTIF returns erroneous results when used with regular expressions, in particular when the "*" wildcard is involved. An example: the pattern "4*" fails to match cells which contain "4A", "4AA" or "4B"; meanwhile, the pattern "4A*" matches "4A" and "4AA".
Created attachment 13272 [details] Spreadsheet (.sxc) showing the described issue
Hi, this is not a bug of OOo Calc. Just switch on the option 'Enable regular expressions in formulas' under tools options spreadsheet calculate. Make also sure that you use the correct syntax for regular expressions. Frank
closed wfm
Hi, extract from a PM : In the file I supplied, the pattern "4." matches "4A" and "4B", producing "2" as a result. The problem is that while "4." works, "4*" fails to match any of the cells that have contents beginning with "4", as expected, resulting in a "0" response. ---- Ok, if the reg. expressions are switched on, the second part of my answer comes true. the * alone is not a valid regular expression. To achieve your goal, the formulas must have this form : =COUNTIF(A1:A6;"4.*") =COUNTIF(A1:A6;"4.") =COUNTIF(A1:A6;"4A.*") =COUNTIF(A1:A6;".*A") Hope this sheds some light on it. Frank