InStrRev

Locates the last occurrence of a substring or character within a string

Syntax
	KeyPgDeclareDeclare KeyPgFunctionFunction InStrRev ( KeyPgByrefByRef str KeyPgAsAs KeyPgConstQualifierConst KeyPgStringString, [ Any ] KeyPgByrefByRef 
	substring KeyPgAsAs KeyPgConstQualifierConst KeyPgStringString, KeyPgByvalByVal start KeyPgAsAs KeyPgIntegerInteger = -1 ) KeyPgAsAs KeyPgIntegerInteger
	KeyPgDeclareDeclare KeyPgFunctionFunction InStrRev ( KeyPgByrefByRef str KeyPgAsAs KeyPgConstQualifierConst KeyPgWstringWString, [ Any ] KeyPgByrefByRef 
	substring KeyPgAsAs KeyPgConstQualifierConst KeyPgWstringWString, KeyPgByvalByVal start KeyPgAsAs KeyPgIntegerInteger = -1 ) KeyPgAsAs KeyPgIntegerInteger

Usage
	last = InStrRev( str, [ Any ] substring [, start ]  )

Parameters
	str
		The string where to search.
	substring
		The substring to find.
	start
		The position in str at which the search will begin. The first 
		character starts at position 1.

Return Value
	The position of the last occurrence of substring in str.

Description
	Locates the position of the last occurrence of a substring or character 
	within a string.  If start parameter is not given or is less than zero, 
	the search begins at the last character.

	Zero (0) is returned if:
		* substring is not found, or
		* either str or substring is an empty strings, or 
		* start is zero, or 
		* start is greater than the length of str.

	If the Any keyword is specified, InStrRev returns the last occurrence of 
	any character in substring.

Example
	' It will return 4
	Print InStrRev("abcdefg", "de")

	' It will return 0
	Print InStrRev("abcdefg", "h")

	Dim test As String
	Dim idx As Integer

	test = "abababab"
	idx = InStrRev(test, "b")

	Do While idx > 0 'if not found loop will be skipped
	   Print """b"" at " & idx
	   idx = InStrRev(Test, "b", idx - 1)
	Loop

'A Unicode example:
dim text as wstring*20
text = "&#1055;&#1088;&#1080;&#1074;&#1077;&#1090;, &#1084;&#1080;&#1088;!"
print instrrev(text,"&#1077;&#1090;") ' displays 5

Platform Differences
	* The wide-character string version of InStrRev is not supported for 
	  DOS target.

Dialect Differences
	* Not available in the CompilerOptlang-lang qb dialect unless referenced with the 
	  alias __Instrrev.

Differences from QB
	* New to FreeBASIC

See also
	* KeyPgInstrInStr
	* KeyPgMidfunctionMid (Function)

