dimanche 19 avril 2015

Remove unclosed brackets python re

How to remove unclosed brackets and its contents if after they have closed block. For example:



"(eaardf((eaar)(eaar" -> "eaardf((eaar)"


I do so, but I can not make a correct regex:



import re

str1 = '(eaardf((eaar)(eaar'
p = re.compile(r'\([a-z)]*.*')
p.sub('', str1)
>>> ''


Please help!


Aucun commentaire:

Enregistrer un commentaire