"For developers", "Server scripts", "Functions description", "Strings", "Pos"
Searching the specified substring in a string. The letter case is important.
function Pos(sSubSt, sSt: string): integer;
Parameter |
Type |
Value |
---|---|---|
sSubSt |
string |
substring that you need to find; |
sSt |
string |
source string for searching. |
Returns the index of the substring. If the substring is not found, the function returns 0. Numeration of characters begins from 1.
const
sSt = 'Yesterday all my troubles seemed so far away, now it looks as though they''re here to stay.';
sFind = 'away';
var
x: integer;
begin
mLogScript('Original string: "' + sSt + '"', '');
mLogScript('Try to find the "' + sFind + '" string', '');
x := pos(sFind, sSt);
if x = 0 then mLogScript('not found', '')
else mLogScript('String "' + sFind + '" is found. Position: ' + inttostr(x), '');
end.
[14:26:35] (Log "Pos"): Original string: "Yesterday all my troubles seemed so far away, now it looks as though they're here to stay."
[14:26:35] (Log "Pos"): Try to find the "away" string
[14:26:35] (Log "Pos"): String "away" is found. Position: 41