import re mystr = "I want to Remove all white spaces, new lines and tabs " print re.sub(r"W", "", mystr) Output : IwanttoRemoveallwhitespacesnewlinesandtabs