瑞文文摘

delphi字符串替换分割函数



标签:delphi,函数

//delphi分割字符串,
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;
delphi字符串列表(TStrings)中字符串替换函数代码
//TStrings中的字符串替换,在win xp, delphi 7下测试通过
//参数和StringReplace的参数相同,除了第一个参数为TStrings和返回值,第一个参数即作为输入参数,也作为输出参数
procedure StringsReplace(var S : TStrings; OldPattern, NewPattern: string; Flags: TReplaceFlags);
var i : integer;
tmpstr : string;
begin
for i := 0 to S.Count -1 do
begin
tmpstr := S[i];
s[i] := StringReplace(tmpstr, OldPattern, NewPattern, Flags);
end;
end;


上一篇:小数的初步认识【教学设计,教案】

下一篇:怎样帮助孩子制定合理的期末考试目标?



瑞文软件工作室 版权所有 [冀ICP备17033643号]
[联系我们][访问电脑版]