  The R*-operation by Chetyrkin, Tkachov, and Smirnov is a generalisation of
the BPHZ R-operation, which subtracts both ultraviolet and infrared divergences
of euclidean Feynman graphs with non-exceptional external momenta. It can be
used to compute the divergent parts of such Feynman graphs from products of
simpler Feynman graphs of lower loops. In this paper we extend the R*-operation
to Feynman graphs with arbitrary numerators, including tensors. We also provide
a novel way of defining infrared counterterms which closely resembles the
definition of its ultraviolet counterpart. We further express both infrared and
ultraviolet counterterms in terms of scaleless vacuum graphs with a logarithmic
degree of divergence. By exploiting symmetries, integrand and integral
relations, which the counterterms of scaleless vacuum graphs satisfy, we can
vastly reduce their number and complexity. A FORM implementation of this method
was used to compute the five loop beta function in QCD for a general gauge
group. To illustrate the procedure, we compute the poles in the dimensional
regulator of all top-level propagator graphs at five loops in four dimensional
phi^3 theory.
