Scope
Objects: Procedures, Transactions, Web Panels, Work Panels Languages: .NET, Java, Ruby, Visual FoxPro
Purpose
To allow searching for a string within another one.
Syntax
StrSearch( 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
StrSearch returns the position (integer index starting at 1) of the Str1 string where the Str2 string was found. It searches from front to back. The starting position in the search is optional. If it is omitted, then the starting position is the position 1 of the Str1 string.
Notes:
The StartChar parameter is of the positive number type, and indicates the initial position of the search within the Str1. If it is 0, then 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, then both functions return 0, since the search cannot be carried out.
If Str2 is empty, it returns StartChar if it was initialized. Otherwise, it returns 1.
Example&str1 ="StrSearch function tests"
StrSearch(&str1,"j") returns 0 (not found) StrSearch(&str1,"a" ) returns 6 StrSearch(&str1, "e" , 7) returns 21
See Also
IndexOf Method StrReplace Function Disponible IV
|