Finds the index of one string within another string. Searches from the end of the string to the beginning.
strrindx(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. where will be searched from this point backward for what.
y (scalar) – contains the index of the last occurrence of what, within where, which is less than or equal to start. If no occurrence is found, it will be 0.
A negative value for start causes the search to begin at the end of the
string. An example of the use of
strrindx() is extracting a file name from
a complete path specification:
path = "/gauss/src/ols.src"; ps = "/"; pos = strrindx(path, ps, -1); if pos; name = strsect(path, pos+1, strlen(path)-pos); else; name = ""; endif;
The above code makes the following assignments:
pos = 11 name = ols.src