regex - How can i find all digits in a string using regexps in python -
this question has answer here:
- does “\d” in regex mean digit? 5 answers
hello iam trying find degits in string returns empty list
my code :
import re re.findall(r'/d','5585858') >>>> []
what error please ?
you have wrong pattern, need \d
first , of digits can add +
\d
match 1 or more combine of digits :
re.findall(r'\d+','5585858')
also based on string can use other functions re.search
may more efficient.
and if want convert string list can use list
:
>>> list('5585858') ['5', '5', '8', '5', '8', '5', '8']
Comments
Post a Comment