How can I write a regex for parsing version numbers. I want to match numbers like: 1.000, 1.0.00, 1.0.0.000 but not integers 1
1.000
1.0.00
1.0.0.000
1
I think you want something like this,
(?:(\d+\.[.\d]*\d+))
OR
(?:(\d+\.(?:\d+\.)*\d+))
DEMO
>>> import re >>> str = 'foobar 1.000, 1.0.00, 1.0.0.000 10 100 foo bar foobar' >>> m = re.findall(r'(?:(\d+\.(?:\d+\.)*\d+))', str) >>> m ['1.000', '1.0.00', '1.0.0.000']