delphi 截取两个字符之间的内容


本文整理自网络,侵删。

 

function copyBegin2EndStr(begindex, endindex, source: string): string; //截取两个字符之间的内容
var
  n, m: Integer;
begin
  n := Pos(begindex, source);
  m := Pos(endindex, source);
  Result := Copy(source, n + 1, m - n - 1);
end;


function GetStrBetween(const SrcStr, AStartTag, AEndTag: string): string; //推荐使用这个 20200111 添加
var
  I, k: Integer;
  lSrc: string;
begin
  lSrc := SrcStr;
  I := pos(AStartTag, lSrc);
  if I > 0 then
  begin
    Delete(lSrc, 1, I + Length(AStartTag) - 1);
    k := pos(AEndTag, lSrc);
    if k > 0 then
    begin
      Result := Copy(lSrc, 1, k - 1);
      Exit;
    end;
  end;
  Result := '';
end;

另外一个截取用法:http://www.delphitop.com/html/zifuchuan/4930.html
http://www.delphitop.com/html/zifuchuan/505.html

相关阅读 >>

Delphi 游戏是如何检测到有od等调试工具的

Delphi renamefile 文件改名

Delphi idhttp上传图给asp完美解决

Delphi 如何解析网址?

Delphi 免杀下载者代码

Delphi最简单的多线程网页采集

Delphi 内存管理[3]

Delphi memo1 行随机打乱

Delphi idhttp中get与post的区别

Delphi httpencode

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



打赏

取消

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

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

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

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

评论

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