indexOf ( string text , string toFind , int _fromIndex , bool[default:false] _fromEnd ) : int
Returns the position of the first occurrence of specified character(s) in a string.
You can reverse this behavior with the _fromEnd argument.
If nothing is found, -1 is returned.
Example
myStr = "Hello planet earth, you are a great planet.";
index=indexOf(myStr,"e", 5) //Find the first occurrence of the letter "e" in a string, starting the search at position 5:
//-> Result : 10
if(index>-1)
{
...
}
Parameters
text
Text to analyse
toFind
String to find in text
_fromIndex (optional)
The index position to start the search from
_fromEnd (optional)
If true, instead of searching the first index, we search the last. In this case the search starts from the end of the string and goes to the beginning (similar to the Java lastIndexOf function).
Return value
Returns the index of the string toFind in text.
If the index is not found, returns -1.
If text or toFind is null returns -2.