I want to parse a simple string with python as -
Limits paramA : (7, 45) paramB : (0, 0) paramC : (1, 23)
I want to extract 7, 45, 0, 0, 1, 23 in different integers. Could someone tell me how can I extract this?
There are lot of string parsing questions in the forum, but I am not able to find the answer that suits me best.
Thank You.
using regex:
In [71]: import re
In [72]: strs="Limits paramA : (7, 45) paramB : (0, 0) paramC : (1, 23)"
In [74]: [int(digit) for digit in re.findall(r'\d+',strs)]
Out[74]: [7, 45, 0, 0, 1, 23]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With