Finds the index of one string within another string.
strindx(where, what, start)¶
- where (string or scalar) – the data to be searched.
- what (string or scalar) – the substring to be searched for in where.
- start (scalar) – the starting point of the search in where for an occurrence of what. The index of the first character in a string is 1.
y (scalar) – contains the index of the first occurrence of what, within where, which is greater than or equal to start. If no occurrence is found, it will be 0.
An example of the use of this function is the location of a name within a string of names:
// String to search in where = "nameagepaysex"; // String to search for what = "pay"; // Find starting index of 'what' y = strindx(where, what, 1);
The above code will set y equal to:
This function is used with
strsect() for extracting substrings.