Algosim documentation: StringIndices

StringIndices

Returns a list with the positions of all occurrences of a given substring in a string.

Syntax

Description

If s and x are strings, then StringIndices returns the list with the positions of all occurrences of x in s, subject to any additional restrictions imposed by the remaining arguments. The list is sorted.

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, StringIndices will begin searching s for x at character index δ in s (the first character having index 1).

Examples

Alice ≔ ExampleData("Alice in Wonderland");
StringIndices(Alice, "rabbit", "i") \ 10
118
696
850
1069
1260
1455
1605
5390
5675
13749
⋮