Navigation
Synopsis Find the first occurrence of a string in another string.
Function int findFirst(str subject, str find)
Usage import String;
Description Find the first occurrence of string find in string subject. The result is either a position in subject or -1 when find is not found.

Also see findAll and findLast.
Examples
rascal>import String;
ok
rascal>findFirst("abracadabra", "a");
int: 0
rascal>findFirst("abracadabra", "bra");
int: 1
rascal>findFirst("abracadabra", "e");
int: -1
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.