I have different strings of the form _AHDHDUHD[Tsfs (SGYA)]AHUDSHDI_ and I want to cut out the (SGYA) part (always capital letters in round brackets) and eventual spaces directly before or after it. So the result should be _AHDHDUHD[Tsfs]AHUDSHDI_.
I had the idea of matching the content of the square brackets with ([A-Z_])(\[.+\])([A-Z_]) and then doing a split and re-inserting it using re module (although I am not sure which re function is suited for this).
However, this feels inelegant. Is there a regex that would do what I want directly, without the intermediary steps?