Parameter | Type | Description |
---|---|---|
STRING | VALUE(STRING) | The string to search in. |
SUBSTRING | VALUE(STRING) | The substring to search for. |
VALUE(BOOLEAN) | TRUE if the substring is in the provided string, FALSE otherwise. |
This function returns TRUE if the second string is in the first string, or FALSE if not. Both provided values are interpreted as strings before the search. The search is case-sensitive.
This function is similar to StrIndex(), except this returns TRUE when StrIndex would return 0 or greater, and FALSE when it would return -1.
a = strContains("applesauce", "sauce"); // a = true
a = strContains("banana", "na"); // a = true
a = strContains("tomato", "to"); // a = true
a = strContains("oranges", "stuff"); // a = false
a = strContains(12345, 23); // a = true
a = strContains(225.75, "5"); // a = true
a = strContains("ABCDEFG", "a"); // a = false
world
{
start()
{
// Index Search
textln(strIndex("Apples and Oranges", "Apples")); // 0
textln(strIndex("Apples and Oranges", "Pears")); // -1
textln("");
// Index vs. LastIndex
textln(strIndex("Apples and Oranges", "an")); // 7
textln(strLastIndex("Apples and Oranges", "an")); // 13
textln(strIndex("Apples and Oranges", "es")); // 4
textln(strLastIndex("Apples and Oranges", "es")); // 16
textln("");
// Contains
textln(strContains("Apples and Oranges", "Apples")); // true
textln(strContains("Apples and Oranges", "apples")); // false
textln(strContains("Apples and Oranges", "Pears")); // false
textln(strContains(1234, 23)); // true (numbers are converted to strings)
textln(strContains(0.56, ".")); // true (numbers are converted to strings)
textln("");
// Starts With
textln(strStartsWith("Apples and Oranges", "Apples")); // true
textln(strStartsWith("Apples and Oranges", "apples")); // false (case sensitive)
textln(strStartsWith("Apples and Oranges", "C")); // false
textln(strStartsWith(123456, 123)); // true (numbers are converted to strings)
textln(strStartsWith(5 + 5, "1")); // true (numbers are converted to strings)
textln("");
// Ends With
textln(strEndsWith("Apples and Oranges", "Oranges")); // true
textln(strEndsWith("Apples and Oranges", "oranges")); // false (case sensitive)
textln(strEndsWith("Apples and Oranges", "z")); // false
textln(strEndsWith(123456, 456)); // true (numbers are converted to strings)
textln(strEndsWith(-1.4, ".4")); // true (numbers are converted to strings)
quit;
}
}