Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extract number outside the parentheses in python

I have the problem with this string

'4.0718393*nt(placement5,placement6)+4.021677*nt(placement4)'

and want have this result

[4.0718393, 4.021677]

Simply said, I want to extract the numbers outside the parentheses in python. I found this regex pattern which will extract every number in a string and is not helping me get further.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

re.findall("[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", string) 

Much appreciated!

>Solution :

Does this answer your question?

import re

text = '4.0718393*nt(placement5,placement6)+4.021677*nt(placement4)'
matches = re.findall(r"\d+\.\d+", text)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading