Suppose this string:
The fox jumped over the log.
Turning into:
import re string = re.sub('[ \t\n]+', ' ', 'The quick brown \n\n \t fox')
This will remove all the tabs, new lines and multiple white spaces with single white space.