#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
text = "aaaa[ab][cd][ef]"
a = re.compile("^(\w+)(\[\w+\])*$").findall(text)
print a
i need all of them but it returns:
[('aaaa', '[ef]')]
with:
a = re.compile("\[\w+\]").findall(text)
i get all of them but the first word is out…
['[ab]', '[cd]', '[ef]']
this text is random text i put this because of the stackoverflow standars quality
finally i do it with this code:
output:
all these solutions are great, thanks 🙂