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 console 清屏代码

Delphi 只限制到4位小数级别

Delphi 用webbrowser给要访问的页面加上referer(来路)参数

Delphi 删除memo某一行

Delphi汇编级初探

Delphi 如何在窗体标题栏添加按钮

Delphi日期函数、日期加减

Delphi打开关闭光驱

Delphi代码实现窗口最小化,最大化,关闭消息发送

Delphi 根据经纬度计算地球上两点之间的距离

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



打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...