lw549的专栏

革命尚未失败,同志仍需努力

原创 取得字符串中指定子字符串出现第n次的位置,效率不高,勉强可用收藏

function GetNSubStringPos(N: Integer; SubString,AString: String): Integer;
//返回第n个SubString在AString中出现的位置
//如果没找到,返回-1
var
  FindCount: Integer;
  Pos: Integer;
begin
  Result := -1;
  Pos := 0;
  for FindCount := 1 to N do begin
    Inc(Pos);
    while MidStr(AString, Pos, Length(SubString)) <> SubString do begin
      if Length(AString) < Length(SubString) + Pos then
        Exit;//未找到
      Inc(Pos);
    end;
  end;
  Result := Pos;
end;

发表于 @ 2005年01月05日 11:46:00|评论(loading...)

新一篇: [Warning] :Symbol 'CmdShow' is specific to a platform | 旧一篇: 创建快捷方式到[启动]

用户操作
[即时聊天] [发私信] [加为好友]
五四九
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
文章分类
    收藏
      c/c++相关
      delphi相关
      阿贵
      朋友
      自己
      鸽子
      其他
      软件使用
      存档
      软件项目交易
      Csdn Blog version 3.1a
      Copyright © 五四九