{ 2002.8.5 Kingron } { Source:Source string } { Sub:Sub string } { Return:Count } { Ex:StrSubCount('abcdbcd','bc')=2 } function StrSubCount(const Source, Sub: string): integer; var Buf : string; i : integer; Len : integer; begin Result := 0; Buf:=Source; i := Pos(Sub, Buf); Len := Length(Sub); while i <> 0 do begin Inc(Result); Delete(Buf, 1, i + Len -1); i:=Pos(Sub,Buf); end; end; { StrSubCount }
function CountChar(TheStr:String;TheChar:Char):Integer; var iTmp:Integer; iPos:Integer; begin iTmp:=0; for iPos:=Length(TheStr) downto 1 do if TheStr[iPos]=TheChar then iTmp:=iTmp+1; Result:=iTmp; end;
{ Source:Source string }
{ Sub:Sub string }
{ Return:Count }
{ Ex:StrSubCount('abcdbcd','bc')=2 }
function StrSubCount(const Source, Sub: string): integer;
var
Buf : string;
i : integer;
Len : integer;
begin
Result := 0;
Buf:=Source;
i := Pos(Sub, Buf);
Len := Length(Sub);
while i <> 0 do
begin
Inc(Result);
Delete(Buf, 1, i + Len -1);
i:=Pos(Sub,Buf);
end;
end; { StrSubCount }
var
iTmp:Integer;
iPos:Integer;
begin
iTmp:=0;
for iPos:=Length(TheStr) downto 1 do
if TheStr[iPos]=TheChar then
iTmp:=iTmp+1;
Result:=iTmp;
end;