A search for a new heavy gauge boson W' decaying to an electron or muon, plus a low mass neutrino, is presented. This study uses data corresponding to an integrated luminosity of 5.0 fb(-1), collected using the CMS detector in pp collisions at a centre-of-mass energy of 7TeV at the LHC. Events containing a single electron or muon and missing transverse momentum are analyzed. No significant excess of events above the standard model expectation is found in the transverse mass distribution of the lepton-neutrino system, and upper limits for cross sections above different transverse mass thresholds are presented. Mass exclusion limits at 95% CL for a range of W' models are determined, including a limit of 2.5TeV for right-handed W' bosons with standard-model-like couplings and limits of 2.43-2.63 TeV for left-handed W' bosons, taking into account their interference with the standard model W boson. Exclusion limits have also been set on Kaluza-Klein W-KK states in the framework of split universal extra dimensions.