I want to remove the [] and contents if there is at least one non digit within the [].
Input: Tag1[aA], Tag2[55].AA[*], Tag3[A1];
Output: Tag1, Tag2[55].AA, Tag3;
I have tried the below, however it only works on exact matches within the brackets.
import re
line = "'Tag1[aA], Tag2[55].AA[*], Tag3[A1];"
# removes the [] if contents contain non digits only
pattern = r'\[\D+\]'
s = re.sub(pattern, '', line)
print(s)
> "'Tag1, Tag2[55].AA, Tag3[A1];"