(count: (a:1,2,3,2,1), 1, 2) produces 4.
(count: "Though", "ugh","u","h") produces 4.
You can think of this macro as being like the
contains operator, but more powerful.
false if occurrences of the right side
appear in the left side, (count:) produces the actual number of occurrences.
Note that if you only want to check if an array or string contains any or all of the
values, it's easier to use
contains with the
all property like so:
$arr contains all of (a:1,2)
$arr contains any of (a:1,2). But, if you need an exact figure for the number of occurrences,
this macro will be of use.
If you use this with a string, and the values aren't also strings, then an error will result.
Substrings are counted separately from each other - that is, the string “Though” contains “ugh” once and “h”
(count: "Though","ugh","h") results in 3. To check for “h” occurrences that are not contained in “ugh”,
you can try subtracting two (count:)s -
(count: "Though","ugh") - (count: "Though","h") produces 1.