Exact solutions for nonlinear wave equations