delphi 取出一个字符在字符串出现的次数


本文整理自网络,侵删。

 
function GetStrCounts(ASubStr, AStr: string): Integer;
var
  i: Integer;
begin
  Result := 0;
  i := 1;
  while PosEx(ASubStr, AStr, i) <> 0 do
  begin
    Inc(Result);
    i := PosEx(ASubStr, AStr, i) + 1;
  end;
end;

//PosEx在StrUtils单元




方法2:20190920 补充
function StrPosCount(subs:string;source:string):integer;
var
Str : string;
begin
Result := 0;
str := source;
while Pos(Subs,Str)<>0 do
begin
Delete(Str,Pos(Subs,Str),Length(Subs));
Inc(Result);
end;
end;

相关阅读 >>

Delphi tfdmemtable 更新到数据库

qdac项目

Delphi like 通配符的使用

wmi技术介绍和应用――查询正在运行的进程信息

Delphi 数据集转换json对象

Delphi中输入法模式imemode属性的解释

Delphi xe android 判断自己程序是否是前台程序

Delphi 之 热键组件(thotkey)

Delphi 取windows登录用户名

Delphi树的一些操作

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



打赏

取消

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

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

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

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

评论

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