- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 截取两个字符之间的内容
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;