InStrRev – String Management Function





InStrRev Function


Description

The InStrRev function returns the position of a string within another string, 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.

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$)