The regular expression "[(){}[]]+" (or rather, "[](){}[]+" or "[(){}[\]]+" (as others suggested)) finds the sequence consecutive characters. What you need to do is find all these sequences and join them.
One solution:
brackets = ''.join(re.findall(r"[](){}[]+",s))
Note that I reordered the order of the characters in the class, since ] must be at the beginning of the class so that it is not interpreted as the end of the class definition.
source share