function SplitString(const Source: String): TStringList;
var
tmp: string;
i: Integer;
begin
Result := TStringList.Create;
tmp := Source;
i := Pos('*', Source);
while i <> 0 do
begin
Result.Add(Copy(tmp, 0, i - 1));
Delete(tmp, 1, i);
i := Pos('*', tmp);
end;
Result.Add(tmp);
end;
使用示例:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
tmp: TStringList;
begin
tmp := SplitString('21312*122*25435');
for i := 0 to tmp.Count - 1 do
ShowMessage(tmp.Strings);
tmp.Free;
end;