InStrRev Function

 
Tips >>ASP Functions


WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE

The InStrRev function returns the numeric position of the first occurrence of a specified substring within a specified string when starting from the end (right end) of the string. You can have the search for the substring be sensitive to the case (upper versus lower), or not. The default is to be case sensitive (binary comparison). An output of zero indicates no match. 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.

The Syntax of the InStrRev function is :-

InStrRev(string1,string2[,start[,compare]])

Its Description is :-

Parameter Description
string1 Required. The string to be searched
string2 Required. The string expression to search for
start Optional. Specifies the starting position for each search. The search begins at the last character position by default (-1)
compare

Optional. Specifies the string comparison to use. Default is 0
Can have one of the following values:

  • 0 = vbBinaryCompare - Perform a binary comparison
  • 1 = vbTextCompare - Perform a textual comparison

Example#1 :-

Code :-
<% =InStrRev("ABCDE ABCDE", "C") %>
Output :-

9

Example#2 :-

Code :-
<% =InStrRev("ABCDE ABCDE", "C", 4) %>
Output :-

3

Example#3 :-

Code :-
<% =InStrRev("ABCDE ABCDE", "c", 4, 0) %>
Output :-
0

Example#4 :-

Code :-
<% =InStrRev("ABCDE ABCDE", "c", 4, VBTextCompare %>
Output :-
3

Example#5 :-

Code :-
dim txt,pos
txt="This is a beautiful day!"
pos=InStrRev(txt,"his")
document.write(pos)
Output :-

2

Example#6 :-

Code :-
dim txt,pos
txt="This is a beautiful day!"
'textual comparison
pos=InStrRev(txt,"B",-1,1)
document.write(pos)
Output :-

11

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

+91-9967648641

+91-9967648641