Long term regularity of some periodic nonlinear dispersive equations