Skip to content

Instantly share code, notes, and snippets.

@KingCprey
Created November 25, 2016 22:41
Show Gist options
  • Save KingCprey/197bf8676413744d21b9d9f53e72980e to your computer and use it in GitHub Desktop.
Save KingCprey/197bf8676413744d21b9d9f53e72980e to your computer and use it in GitHub Desktop.
Python methods to extract
def extractDigits(s):return "".join(filter(str.isdigit,s))
def extractInt2(s):return int(filter(str.isdigit,s))
def extractInt3(s):return int("".join(filter(str.isdigit,s)))
s="abc100"
#Return string
"".join(filter(str.isdigit,s))
#Return ints
int(filter(str.isdigit,s))
int("".join(filter(str.isdigit,s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment