Searches for a substring in a string.
Kernel.bdh
StrSearch(in sSource : string, in sSearch : string, in nFlags : number) : number;
Index of the position of the found substring, or zero if the substring was not found or an error occurred.
Parameter | Description |
---|---|
sSource | Source string to be searched |
sSearch | String to search for |
nFlags |
Option flags. Several combinations of the following options are possible:
|
dcltrans transaction TStrSearch var sString, sWord : string; nPos : number; begin sString := "The dog, the cat and the mouse are very tired today"; sWord := "the"; write("string = "); write(sString); writeln; write("word = "); write(sWord); writeln; nPos := StrSearch(sString, sWord, STR_SEARCH_FIRST); write("pos = "); write(nPos); writeln; nPos := StrSearch(sString, sWord, STR_SEARCH_NEXT); write("pos = "); write(nPos); writeln; nPos := StrSearch(sString, sWord,STR_SEARCH_FIRST | STR_SEARCH_MATCH_CASE); write("pos = "); write(nPos); writeln; nPos := StrSearch(sString, sWord,STR_SEARCH_FIRST | STR_SEARCH_REVERSE); write("pos = "); write(nPos); writeln; end TStrSearch;
string = The dog, the cat and the mouse are very tired today word = the pos = 1 pos = 10 pos = 10 pos = 22
WebFileUpload01.bdf