StringContains
Tests if a string contains a given substring.
Syntax
-
StringContains(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 StringContains
returns true
iff s
contains x
as a substring, 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:
-
i
: MakesStringContains
search forx
in a case-insensitive manner. -
w
: MakesStringContains
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, StringContains
will begin searching s
for x
at character index δ
in s
(the first character having index 1).
Examples
StringContains("Nargles can be somewhat obnoxious creatures at times.", "nargle")
false
StringContains("Nargles can be somewhat obnoxious creatures at times.", "nargle", "i")
true
StringContains("Nargles can be somewhat obnoxious creatures at times.", "nargle", "iw")
false
Alice ≔ ExampleData("Alice in Wonderland");
StringContains(Alice, "dinner", "iw")
true
StringContains(Alice, "pyruvate dehydrogenase complex", "iw")
false