Home > Language Reference > String Management Functions > InStrRev

InStrRev

The InStrRev function returns the position of a string within another, starting from the right side of the string.

Usage

Used to find out if one set of characters (a string) is contained in another.  

Syntax

var=InStrRev(<source_string>, <string_to_search>)

Parameters

<source_string>, string that will be searched.

<string_to_search>, string to search for. 

Return value

var, integer, position of the first occurrence of <string_to_search> in <source_string> starting with the right side of the string. If no occurrence is found, the return value is 0.

Remarks

Use this function in an If...EndIf block to test if a text is in a string or not.

See also

Asc
Chr$
Encrypt
ExtractBetween$
InStr
LCase$
Left$
Len
LTrim$
Mid$
Replace$
Right$
RTrim$
SplitIntoArray
Str$
Trim$
UCase$
Val

Examples

a$="Hello TesTask, Hellobis"
pos=InstrRev(a$,"Hello")
msgbox(pos) ' returns 16
    
'Path extraction of a long filename including its path
pos=InstrRev("c:\program files (x86)\ wintask\ scripts\my_script.rob","\")
msgbox(pos)
path$=left$("c:\program files (x86)\ wintask\ scripts\my_script.rob",pos)
msgbox(path$)