Template:Count*/doc

Usage

 * counts the number of occurrences of the asterisk (*) in the text.
 * The example returns (should be 3).
 * The example returns (should be 3).

gives (4)

gives because it counts the * from the signature list entries (as long nobody uses * in their sig)

Recursion
This template repeatedly calls itself. Usually Mediawiki detects this and breaks the recursion. The workaround is to use a redirect. Therefore, Template:Count** up to (currently) Template:Count******* redirect to Count*; the number of asterisks indicates the recursion level. Count* can count at most 5*2n-1 asterisks, where n indicates the recursion depth (= number of asterisks). If the asterisks are not evenly distributed throughout the text, the number is somewhat less.

Server Resources
Pre-expand include size: 378101/2097152 bytes Post-expand include size: 63374/2097152 bytes Template argument size: 257545/2097152 bytes #ifexist count: 0/100 Unfortunately this means that using several of these counts on a single page is probably not feasible.

The template can be easily adapted to take the key being counted (currently fixed key=*).