May-10-2020, 06:44 AM
If you're already using a regex, I'd just grab them all in one go. If match is successful, then all the match objects can be pulled out of the groups() method.
import re name = "alpha(beta,gamma)" m = re.match("(\w+)\((\w+),(\w+)\)",name) print(m.groups())
Output:('alpha', 'beta', 'gamma')