VBScript InStrRev Function

The InStrRev function returns the position of the first occurrence of one string within another. The search begins from the end of string, but the position returned counts from the beginning of the string."

Examples

Example 1

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"beautiful"))

%>

The output of the code above will be:

11

Example 2

Finding the letter "i", using different starting positions:

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"i",-1) & "<br />")
response.write(InStrRev(txt,"i",7) & "<br />")

%>

The output of the code above will be:

16
6

Example 3

Finding the letter "T", with textual, and binary, comparison:

<%

txt="This is a beautiful day!"
response.write(InStrRev(txt,"T",-1,1) & "<br />")
response.write(InStrRev(txt,"T",-1,0) & "<br />")

%>

The output of the code above will be:

15
1

❮ Complete VBScript Reference