Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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