import re text pytest4 Unkle -- Never Never Land byt ly 5555 cover bit

1
2
3
4
5
6
7
import re
text = '#pytest4 Unkle -- Never Never Land : byt.ly/5555 cover: bit.ly/2y4lDI tags: trip-hop, idm,Unkle'
twit = re.match('^#pytest4 (?P<artist>.+)\s*--\s*(?P<album>.+)\s*:\s*(?P<link>.+)\s*(?:cover: (?P<cover>.+))?\s*(?:tags: (?P<tags>.+))?$', text)
print twit.groups()
выводит ('Unkle ', 'Never Never Land : byt.ly/5555 cover: bit.ly/2y4lDI tags', 'trip-hop, idm,Unkle', None, None)