unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function SplitString(Source, Deli: string): TStringList; stdcall;
var
EndOfCurrentString: byte;
StringList: TStringList;
begin
StringList := TStringList.Create;
while Pos(Deli, Source) > 0 do
begin
EndOfCurrentString := Pos(Deli, Source);
StringList.add(Copy(Source, 1, EndOfCurrentString - 1));
Source := Copy(Source, EndOfCurrentString + Length(Deli), Length(Source) - EndOfCurrentString);
end;
Result := StringList;
StringList.add(Source);
end;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
str,str1,str2:string;
i:Integer;
lst:TStringList;
begin
str:='无抵|抗|sdfk|jfdk|f';
str1:='|';
lst:=SplitString(str,str1);
for i:=0 to lst.Count -1 do
ShowMessage(lst[i]);
end;
end.
浙公网安备 33010602011771号