Algosim documentation: StringPos

StringPos

Returns the position of the first occurrence of a given substring in a string.

Syntax

Description

If s and x are strings, then StringPos returns the character position of the first character of the first occurrence of x in s subject to any additional restrictions imposed by the remaining arguments. The position of the first character of s is 1. If x isn’t found in s, then 0 is returned.

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

Examples

'("rabbit", "beautiful", "extraordinary", "mirror") @ (word ↦ StringPos(Alice, word, "i"))
118
7731
60887
0