本文整理自网络,侵删。
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》频道 >>