StringPos
Returns the position of the first occurrence of a given substring in a string.
Syntax
-
StringPos(s, x[, f[, δ]])
-
s
is the string to be searched -
x
is the substring to search for -
f
is 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
: MakesStringPos
search forx
in a case-insensitive manner. -
w
: MakesStringPos
only considerx
to be a substring ofs
ifx
is 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