Searches for a string within a string in reverse order and returns the found position counting from the beginning (unless the start position is indicated).
str1.LastIndexOf(str2 [ , start-position ] )
Where:
str1
String on which the search will be done. It may be an attribute or variable based on the Character/VarChar/LongVarChar data type.
str2
Search string. It may be a fixed value, an attribute or variable based on the Character/VarChar/LongVarChar data type.
start-position
Optional. It indicates the search start position. It must be a positive number.
Type Returned:
Numeric
Data Types: Character, VarChar, LongVarChar
Generators:
.NET,
.NET Framework, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)
This method searches for a string within a string in reverse order. If the last parameter is omitted, it searches from the first position of the str1. If the search is not successful, it returns 0.
Notes:
- The start-position parameter must be a positive number. It indicates the initial position of the search within the str1. If it is 0, both functions return to 0.
- The comparison between characters is case sensitive; i.e.: 'a' is different from 'A'.
- If str1 is empty or the length is shorter than str2, both functions return 0, since the search cannot be carried out.
- If str2 is empty, it returns start-position if it was initialized. Otherwise, it returns 1.
&str1 = "Of LastIndexOf test"
&Nbr=&str1.LastIndexOf("e") //&Nbr= 17
&Nbr=&str1.LastIndexOf("In") //&Nbr= 8
&Nbr=&str1.LastIndexOf("Last") //&Nbr= 4
&Nbr=&str1.LastIndexOf("O") //&Nbr= 13
&Nbr=&str1.LastIndexOf("Of") //&Nbr= 13
&Nbr=&str1.LastIndexOf("Of",1) //&Nbr= 1
IndexOf method
StrSearchRev function
StrReplace function