VBScript » Functions » InStrRev

Version: 2.0

Syntax:
InStrRev(String, Substring, Start, Compare)
String
The String argument is the string in which you will search.
Substring
The Substring argument is the substring you are searching
Start
The optional Start argument is the numeric position, counted from the left, which defines where to start the search for the substring.
Compare
The optional Compare argument can be used to set whether the search for the substring is case sensitive (upper versus lower), or not. You must only use either a constant or value from the Comparison Constants table.

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.

Comparison Constants

CONSTANT VALUE DESCRIPTION
VBBINARYCOMPARE 0 Binary comparison

(case sensitive)
VBTEXTCOMPARE 1 Text Comparison

(case insensitive)
VBDATABASECOMPARE 2 Compare information inside database

Examples

Code:
<% =InStrRev("ACBED ABCDE", "C") %>
Output:
9
Language(s): VBScript
Code:
<% =InStrRev("ACBED ABCDE", "C", 4) %>
Output:
2
Explanation:

In the example the search begins at postion 4, counted from the left, and the search goes from the right to left.

Language(s): VBScript
Code:
<% =InStrRev("ACBED ABCDE", "c", 4, 0) %>
Output:
0
Explanation:

In the example, by using VBBinaryCompare, or 0, for the Compare argument, all upper/lower case differences are obeyed in both the search.

Language(s): VBScript
Code:
<% =InStrRev("ACBED ABCDE", "c", 4, VBTextCompare %>
Output:
2
Explanation:

In the example, by using VBTextCompare, or 1, for the Compare argument, all upper/lower case differences are ignored in the search.

Language(s): VBScript

See Also: