StrSearchRev Function

Official Content
This documentation is valid for:

To allow searching for a string within a string in reverse order.  

Syntax

StrSearchRev( str1, str2 [ , start_char ] )

Type Returned:
Numeric

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

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

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

Description

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.

Notes:

 

  • 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. 

Examp

&str1 = "StrSearch function tests"

StrSearchrev(&str1, "a") Returns 6
StrSearchrev(&str1, "fun" ,20)  returns 11

Scope

Objects: Procedures, Transactions, Web Panels
Languages: .NET, Java, Ruby, Visual FoxPro

See Also

LastIndexOf Method
StrSearch function
StrReplace function






Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.