function MidStr(const S, SLeft, SRight: string): string;
var
PosLeft, PosRight, PosMid: Integer;
STmp: string;
begin
Result := '';
PosLeft := Pos(SLeft, S);
if PosLeft = 0 then Exit;
PosMid := PosLeft + Length(SLeft);
STmp := Copy(S, PosMid, Length(S));
PosRight := Pos(SRight, STmp);
if PosRight = 0 then Exit;
Result := Copy(STmp, 1, PosRight - 1);
end;