Regularity of solutions of critical and subcritical nonlinear wave equations