So I have this king of string:
some_string-1.4.2.4-RELEASE.some_extension
And I want to parse the version number (in my example: 1.4.2.4)
But the number between the dots will not always be 1 digit, it could be something like: 1.40.2.4 or 11.4.2.4.
This is what i have tried:
(\d+\.)?\d+\.\d+
And this does not parse all the numbers.
EDIT
I tried to use the answer from the duplicate link: \d+(\.\d+)+
And according to regex101 I get this result:
Full match 17-24 1.4.2.4
Group 1. 22-24 .4
But in my code I got only .4:
file_name = 'some_string-1.4.2.4-RELEASE.some_extension'
match = re.findall('\d+(\.\d+)+', file_name)
if len(match) == 0:
print('Failed to match version number')
else:
print(match[0])
return match[0]