函数代码
function CountDelims(const S, Delims: string): Integer;
var
Idx: Integer; //loops thru all characters in string
begin
Result := 0;
for Idx := 1 to Length(S) do
if IsDelimiter(Delims, S, Idx) then
Inc(Result);
end;
测试
procedure TForm1.FormCreate(Sender: TObject);
begin
caption:=CountDelims('a|b|c', '|').ToString;
end;