Bug 99181 - CountIf ? (german: ZÄHLENWENN) with regexp does not count correctly
Summary: CountIf ? (german: ZÄHLENWENN) with regexp does not count correctly
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.0.5.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-09 14:55 UTC by Tom
Modified: 2016-04-10 08:54 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
screenshot with formula and result in Cell K217 (14.03 KB, image/png)
2016-04-09 14:55 UTC, Tom
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom 2016-04-09 14:55:16 UTC
Created attachment 124204 [details]
screenshot with formula and result in Cell K217

Formula
=ZÄHLENWENN($N217:$AD217;".*mo|mw|ma|ml|mu|my.*")

does not count cells with following content 
ml,5
(option regexp. within formulas is switched on!)

but does correctly count cells with content
ml

Something seems wrong.
Comment 1 GerardF 2016-04-09 16:57:47 UTC
The 1st .* applies only to 1st criterion "mo" and the last to "my".
Using parenthesis make the formula giving expected result :

=ZÄHLENWENN($N217:$AD217;".*(mo|mw|ma|ml|mu|my).*")
Comment 2 Tom 2016-04-09 20:15:20 UTC
Thank you!
Regexp ".*(mo|mw|ma|ml|mu|my).*" works fine! 
Hope this is explained in documentation/help ...

The following comment is not too important (as it works with the above): 
still the behaviour seems to me not intuitive.
In short: if ".*mo|mw|ma|ml|mu|my.*" matches 
ml
why does it not match
mlm
as is the case?
i.e., it only matches if the cell contains exactly ml and no character before nor any character thereafter.

So ".*mo|mw|ma|ml|mu|my.*" seems to work exactly like
"mo|mw|ma|ml|mu|my"
Comment 3 GerardF 2016-04-10 08:54:12 UTC
(In reply to Tom from comment #2)

> In short: if ".*mo|mw|ma|ml|mu|my.*" matches 
> ml
> why does it not match
> mlm
> as is the case?
> i.e., it only matches if the cell contains exactly ml and no character
> before nor any character thereafter.
> 
> So ".*mo|mw|ma|ml|mu|my.*" seems to work exactly like
> "mo|mw|ma|ml|mu|my"

No, this search matches:
.*mo
mw
ma
ml
mu
my.*

Word ending with "mo", words beginning with "my" and exact match for others.
"hel|hal.*" with find exact match "hel" and words beginning with "hal".
Operator | (or) have priority. (.* applies only to "hal".
While with "(hel|hal).*" will find "hell", "hello", "hallo", "hellish"...
(With the grouping parenthesis, ".*" apllies to all the group.)