function ReplaceMidStr(const S, SLeft, SRight, NewStr: string): string;
var
PosLeft, PosRight, PosMid: Integer;
STmp: string;
begin
Result := S;
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;
Delete(STmp, 1, PosRight - 1);
Result := Copy(S, 1, PosMid - 1) + NewStr + STmp;
end;