Indexof method:
ReturnStringThe first occurrence of a substring in an object.
Strobj. indexof (substring [, startindex])
Parameters
Strobj
Required. String object or text.
Substring
Required. The substring to be searched in the string object.
Starindex
Optional. This integer indicates the index in the string object. If it is omitted, It is searched from the beginning of the string.
Description
The indexof method returns an integer indicating the starting position of the substring in the string object. If no substring is found,-1 is returned.
If startindex is negative, startindex is treated as zero. If it is larger than the index at the largest character location, it is regarded as the largest possible index.
Search from left to right. Otherwise, this method is the same as lastindexof.
Lastindexof method:
ReturnStringPosition of the final occurrence of the object neutron string.
Strobj. lastindexof (substring [, startindex])
Parameters
Strobj
Required. String object or text.
Substring
Required. The substring to be searched in the string object.
Startindex
Optional. This integer indicates the starting index position of the string object. If omitted, the search starts from the end of the string.
Description
The lastindexof method returns an integer indicating the starting position of the substring in the string object. If no substring is found,-1 is returned.
If startindex is negative, startindex is treated as zero. If it is larger than the index at the largest character location, it is regarded as the largest possible index.
Search from right to left. Otherwise, the method is the same as indexof.