Skip to content

Instantly share code, notes, and snippets.

@mitchellrj
Created September 4, 2012 15:23
Show Gist options
  • Save mitchellrj/3622350 to your computer and use it in GitHub Desktop.
Save mitchellrj/3622350 to your computer and use it in GitHub Desktop.
Replace whitespace at the beginning of non-empty lines
import re
def strip_non_empty_lines(text):
return re.sub(r'^\s+(?=\S)', '', text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment