Delphi 删除指定字符串的所有实例


本文整理自网络,侵删。

 
uses   types, registry, dateUtils,
  shlobj, shellapi, activex, comobj, strutils, psAPI, math,iniFiles;


function idxOf(s:string; a:array of string; isSorted:boolean=FALSE):integer;
var
  r, b, e: integer;
begin
if not isSorted then
  begin
  result:=ansiIndexText(s,a);
  exit;
  end;
end;

function removestring(var a:TStringDynArray; idx:integer; l:integer=1):boolean;
begin
result:=FALSE;
if (idx<0) or (idx >= length(a)) then exit;
result:=TRUE;
while idx+l < length(a) do
  begin
  a[idx]:=a[idx+l];
  inc(idx);
  end;
setLength(a, idx);
end; // removestring

// remove all instances of the specified string
procedure removeStrings(find:string; var a:TStringDynArray);
var
  i, l: integer;
begin
  repeat
  i:=idxOf(find,a);
  if i < 0 then break;
  l:=1;
  while (i+l < length(a)) and (ansiCompareText(a[i+l], find) = 0) do inc(l);
  removeString(a, i, l);
  until false;
end; // removeStrings

相关阅读 >>

Delphi tchart分析报告

Delphi xe [dcc32 fatal error] f2039 could not create output file 问题的解决

Delphi excel数据导入数据库表

Delphi for 循环的例子 多种用法

Delphi udp文件传输

Delphi xe10 fdmemtable 数据保存本地和从本地加载

Delphi xe10 创建匿名线程

Delphi deletefile 删除文件

Delphi adoquery的post和updatebatch

Delphi模仿“千千静听”滚动标题栏,非常简单!

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...