Official Content

Searches for a string within a string in reverse order.  


StrSearchRev( str1, str2 [ , start_char ] )


    String on which the search will be done. It may be of the Char, Varchar or Long varchar type.

    Search string. It may be of the Char, Varchar or Long varchar type.

    Optional. It indicates the search start position. This variable is of the positive number type.

Type Returned:


Objects: Procedure, Transaction, Web Panel, Panel, Data Provider
Generators: .NET, .NET Framework, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3), Apple, Android, Angular


StrSearchRev returns the position of the Str1 string where the Str2  string was found.  It searches from back to front. If the last parameter is omitted, it searches from the final position of the Str1, backwards. 
If the search is not successful, it returns to 0.

  • The StartChar parameter is  of the positive number type and indicates the initial position of the search within the Str1.  If 0, the function returns 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, the function returns 0, since the search cannot be carried out.
  • If Str2 is empty, it returns StartChar if it was initialized; otherwise, it returns StrLen. 


&str1 = "StrSearch function tests"
StrSearchrev(&str1, "a") //Returns 6
StrSearchrev(&str1, "fun" ,20)  //Returns 11

See Also

LastIndexOf method
StrSearch function
StrReplace function

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant