//分割一个字符串,其中分割的标志是 SubStr function SplitString(const Source, SubStr: String): TStrings; var tempStr : String; I : Integer; begin Result := TStringList.Create; tempStr := Source; I := Pos(SubStr, Source); while I <> 0 do begin Result.Add(Copy(tempStr, 0, I - 1)); Delete(tempStr, 1, I); I := Pos(SubStr, tempStr); end; Result.Add(tempStr); end;
Function SpString(S:String):TStringList; var i:integer; Str:string; SList:TStringList begin SList:=TStringList.Create ; str:=S; i:=ansipos(',',Str); if i=0 then Slist.add(S); while i<>0 do begin Slist.add(copy(Str,1,i-1)); Str:=copy(Str,i+1,length(Str)-i); i:=ansipos(',',Str); end; Result := SList; end;
function SplitString(const Source, SubStr: String): TStrings;
var
tempStr : String;
I : Integer;
begin
Result := TStringList.Create;
tempStr := Source;
I := Pos(SubStr, Source);
while I <> 0 do
begin
Result.Add(Copy(tempStr, 0, I - 1));
Delete(tempStr, 1, I);
I := Pos(SubStr, tempStr);
end;
Result.Add(tempStr);
end;
var
i:integer;
Str:string;
SList:TStringList
begin
SList:=TStringList.Create ;
str:=S;
i:=ansipos(',',Str);
if i=0 then Slist.add(S);
while i<>0 do
begin
Slist.add(copy(Str,1,i-1));
Str:=copy(Str,i+1,length(Str)-i);
i:=ansipos(',',Str);
end;
Result := SList;
end;