Algosim documentation: StringCount

StringCount

Counts the number of times a given substring occurs in a string.

Syntax

Description

If s and x are strings, then StringCount returns the number of times x occurs in s, subject to any additional restrictions imposed by the remaining arguments.

f specifies flags for the algorithm. It is a string that can contain zero or more of the following characters:

If omitted, f defaults to "" (no options).

Finally, if δ is specified, StringCount will begin searching s for x at character index δ in s (the first character having index 1).

Examples

Alice ≔ ExampleData("Alice in Wonderland");
'("rabbit", "beautiful", "extraordinary", "mirror") @ (word ↦ StringCount(Alice, word, "i"))
52
15
2
0