16,748
社区成员
发帖
与我相关
我的任务
分享
var
str,sstr,estr:string;
s,e:integer;
begin
str := 'fgjdguyr <$MD5>vs <$MD5>vsvsv </$MD5>vsv </$MD5>uyiryir';
estr := '</$MD5>';
sstr := '<$MD5>';
e := LastDelimiter(estr,str)-Length(estr);
s := Pos(sstr,str)+Length(sstr);
str := Copy(str,s,e-s);
ShowMessage(str);
end;
var
str,sstr,estr:string;
s,e:integer;
begin
str := 'fgjdguyr <$MD5>vs <$MD5>vsvsv </$MD5>vsv </$MD5>uyiryir';
estr := '</$MD5>';
sstr := '<$MD5>';
e := LastDelimiter(estr,str)-+Length(estr);
s := Pos(sstr,str)+Length(sstr);
str := Copy(str,s,e-s);
ShowMessage(str);
end;
function GetSubValue(S: string): String;
const
RexTop = '<$MD5>';
RexBottom = '</$MD5>';
var
i, j : Integer;
iCount: Integer;
begin
Result := '';
i := Pos(RexTop, S);
if i > 0 then
begin
inc (i, Length(RexTop));
iCount := 1;
for j := i to Length(S) - Length(RexBottom) do
begin
if Copy(S, j, Length(RexTop)) = RexTop then
inc(iCount)
else begin
if Copy(S, j, Length(RexBottom)) = RexBottom then
begin
dec(iCount);
if iCount = 0 then
begin
Result := Copy(S, i, j - i);
break;
end;
end;
end;
end;
end;
end;
......
ShowMessage (GetSubValue('fgjdguyr <$MD5>vs <$MD5>vsvsv </$MD5>vsv </$MD5>uyiryir'));
......