Skip to content
Reference > Methods

strIndexOf(text,toFind)

Definition

Integer strIndexOf(String text, String toFind)

Description

Returns the 0 based index of the toFind within the text. If toFind does not exist in text, returns -1.

Parameter Definition

Name Type Description
text String The base string to get a substring from
toFind String the substring to find

Examples

1
2
3
4
5
6
7
8
Integer r1 = strIndexOf("what,now","hat"); // r1 == 1
Integer r2 = strIndexOf("what,now","what"); // r2 == 0
Integer r3 = strIndexOf("What now"," "); // r3 == 4
Integer r4 = strIndexOf("what,now"," "); // r4 == -1
Integer r5 = strIndexOf("what,now",""); // r5 == 0
Integer r6 = strIndexOf("what,now",null); // r6 == -1
Object r7 = strIndexOf(null,"test"); // r7 == null
Integer r8 = strIndexOf("An example,of, multiple, delims",", "); // r8 == 13