delphi字符串列表(TStrings)中字符串替换函数代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

delphi字符串列表(TStrings)中字符串替换函数代码2009年11月04日星期三09:532009年04月12日下午03:47delphi字符串列表(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;

//分割字符串,从网上搜索的也很好使

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;

相关文档
最新文档