Skip to content

Instantly share code, notes, and snippets.

@blackrobot
Created February 5, 2015 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackrobot/ea5dca3f62483245a454 to your computer and use it in GitHub Desktop.
Save blackrobot/ea5dca3f62483245a454 to your computer and use it in GitHub Desktop.
import re
# This removes any leading digits, or whitespace
foo = re.compile(r'^[\d\s]+')
foo.sub('', "0123345 Hello World") # 'Hello World'
# This removes zeros only
bar = re.compile(r'^[0]+')
bar.sub('', "012345 Hello World") # '12345 Hello World'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment