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

How to get multi decimals digit using regex?

I am trying to match the out of the below data which conatins some values in decimals

data = Ver, 3.0.9

for matching I am trying

match =  re.findall(
            r"Ver,\s*\d+.?\d+",
            data,
        )

but I am getting the below output

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

Ver, 3.0 # .9 is missing 

Is there any better way to match this kindly suggest I am aware I can add one more time \d+.?\d+ for matching this particular result but if the values are more than this decimals points it will fail

>Solution :

You can try using the Following regex:

import re

a = '30.0.9'
print(re.findall('[\d+\.]+', a))

Output:

['30.0.9']
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