Created
November 25, 2016 22:41
-
-
Save KingCprey/197bf8676413744d21b9d9f53e72980e to your computer and use it in GitHub Desktop.
Python methods to extract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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