CountStr
From SCAR Divi Manual
Definition
function CountStr(const SubStr, Str: string): Integer;
Source Code
function CountStr(const SubStr, Str: string): Integer; var StrPos, StrLen: Integer; begin StrLen := Length(SubStr); if StrLen = 0 then Exit(0); StrPos := Pos(SubStr, Str); if StrPos > 0 then begin Result := 1; while True do begin StrPos := PosEx(SubStr, Str, StrPos + StrLen); if StrPos > 0 then Inc(Result) else Break; end; end else Result := 0; end;
Availability
SCAR Divi 3.34 > Current
Description
Counts every instance of a string SubStr in a string Str.
Example
begin WriteLn(CountStr('lol', 'lollol lol heylol')); end.
Output:
4