StringPos
Returns the position of the first occurrence of a given substring in a string.
Syntax
-
StringPos(s, x[, f[, δ]])-
sis the string to be searched -
xis the substring to search for -
fis a string -
δis a positive integer
-
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:
-
i: MakesStringPossearch forxin a case-insensitive manner. -
w: MakesStringPosonly considerxto be a substring ofsifxis found as a full word ins.
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