# 0914.py import re testo='ab ps45 za600 bs88' print (re.findall('[a-z]+[0-9]*',testo)) # ['ab', 'ps45', 'za600', 'bs88'] ####################################### print (re.findall('([a-z]+)[0-9]*',testo)) # ['ab', 'ps', 'za', 'bs'] print (re.findall('([a-z]+)([0-9]*)',testo)) # [('ab', ''), ('ps', '45'), ('za', '600'), ('bs', '88')] ####################################### testo='a=6, b=200, at=130' t=re.findall('([a-z]+)\s*=\s*([0-9]+)',testo) print (t) # [('a', '6'), ('b', '200'), ('at', '130')] diz=dict(t) print (diz) # {'a': '6', 'b': '200', 'at': '130'}