在delphi7中增加了idstring单元,里边有一个splitstring函数,对于字符串拆分处理非常方便,但是在delphi6中没有这个单元,我把这个函数原形提出来,在D6下也可以直接使用。
procedure SplitString(const AStr, AToken: String; var VLeft, VRight: String);
var
i: Integer;
LLocalStr: String;
begin
{ It is possible that VLeft or VRight may be the same variable as AStr. So we copy it first }
LLocalStr := AStr;
i := Pos(AToken, LLocalStr);
if i = 0 then
begin
VLeft := LLocalStr;
VRight := '';
end
else
begin
VLeft := Copy(LLocalStr, 1, i - 1);
VRight := Copy(LLocalStr, i + Length(AToken), Length(LLocalStr));
end;
end;