I am trying to figure out a way to extract all characters from a string (
'\', etc...) and isolate the digits for instance:
if I have input:
hey.44.6 how a8re you99? -.23 4
My program needs to be able to extract each digit :
4 then give me the number of integers the string has (this one has 6) and the sum of the numbers.
I am having a really tough time even getting a start to this question, and I've looked at many options including
re. If someone could help me even get a handle on this, it would be greatly appreciated.
You can do it with
re. Here's one way:
>>> re.findall("[0-9]+", s) ['44', '6', '8', '99', '23', '4']