I try get formatting string using python3 regex - re
My input:
{'factorial.2.0.0.zip', 'Microsoft ASP.NET Web API 2.2 Client Libraries 5.2.3.zip', 'Newtonsoft.Json.9.0.1.zip'}
I try get only name and only version for packages, like that:
- factorial.2.0.0.zip
- factorial
- 2.0.0
- Microsoft ASP.NET Web API 2.2 Client Libraries 5.2.3.zip
- Microsoft ASP.NET Web API 2.2 Client Libraries
- 5.2.3
etc. This my code
if diff is not None:
for values in diff.values():
for value in values:
temp = ''
temp1 = ''
temp = re.findall('[aA-zZ]+[0-9]*', value) #name pack
temp1 = re.findall('\d+', value) #version
print(temp)
print(temp1)
My wrong output:
temp:
['Microsoft', 'ASP', 'NET', 'Web', 'API', 'Client', 'Libraries', 'zip']
['Newtonsoft', 'Json', 'zip']
['factorial', 'zip']
temp1:
['2', '0', '0']
['2', '2', '5', '2', '3']
['9', '0', '1']
Right output:
temp:
['Microsoft', 'ASP', 'NET', 'Web', 'API', 'Client', 'Libraries']
['Newtonsoft', 'Json']
['factorial']
temp1:
['2', '0', '0']
['5', '2', '3']
['9', '0', '1']
how me fix problem, delete "zip" is search and extra numbers. Maybe have another way solved my problem.