delphi没有,自己写个吧 function getfield(const sour: string; num: integer; sep: char='|'): string; var count, len, i, j: integer; begin result := ''; len := length(sour); count := 0; if (num < 0) or (len <= num) then exit; for i := 1 to len do begin if count = num then begin j := i; while (sour[j] <> sep) and (j <= len) do begin result := result + sour[j]; j := j + 1; if j > len then exit; end; exit; end else if sour[i] = sep then inc(count); end; end;
没有这样的函数,自己写一个吧 function ExtractFirst(var Str:String):string; //Result为第一个 //剩下的部分在str中 var i:Integer; begin i:=Pos('-',Str); if i=0 then begin Result:=Str; Str=''; end else begin Result:=Copy(str,1,i-1); str:=Copy(str,i+1,10000);//10000应该足够了 end;end;
function getfield(const sour: string; num: integer; sep: char='|'): string;
var
count, len, i, j: integer;
begin
result := '';
len := length(sour);
count := 0;
if (num < 0) or (len <= num) then
exit;
for i := 1 to len do
begin
if count = num then
begin
j := i;
while (sour[j] <> sep) and (j <= len) do
begin
result := result + sour[j];
j := j + 1;
if j > len then
exit;
end;
exit;
end
else if sour[i] = sep then
inc(count);
end;
end;
function ExtractFirst(var Str:String):string;
//Result为第一个
//剩下的部分在str中
var i:Integer;
begin
i:=Pos('-',Str);
if i=0 then
begin
Result:=Str;
Str='';
end
else
begin
Result:=Copy(str,1,i-1);
str:=Copy(str,i+1,10000);//10000应该足够了
end;end;