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 showdebuginfo 窗口

Delphi 截取绝对路径的文件名

Delphi 通过系统api函数实现精确记时

Delphi shellexecute 打开文件夹

Delphi获得硬盘所有分区

Delphi sendmessage这个函数有很多奇妙的用途

Delphi二值图像除杂点(噪点)

Delphi实现身份证号码15到18位升位算法

Delphi webbrowser 跨域访问

Delphi 限制edit输入 多个例子

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



打赏

取消

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

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

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

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

评论

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