Search
Description
This function finds a string (find) within another string (within), starting from position(StartPos), and returns the starting position of find$ in within$. Unlike the Find function, Search is not case sensitive.
Origin's Search function does not allow wildcard characters. For functionality equivalent to MS Excel's Search function, see MatchBegin.
Syntax
int Search(string within$, string find$ [, int StartPos = 1])
NOTE: Order of string arguments is reverse of MS Excel.
Parameters
within
- is the containing string.
find
- is the string you want to find.
StartPos
- specifies the position of the character at which to start the search. The default value is 1, which searches from the first character.
Return
If the string has been found, return the position of the string.
If the string has not been found, return -1.
Example
string str1$ = "abcde"; string str2$ = "BC"; int position = Search(str1$,str2$); position = ; //should return 2