How to remove the following:
- Acronyms starting with opening bracket and followed by upper case or number: e.g. '(ABC' or '(ABC)' or '(ABC-2A)' or '(ABC-1)'.
But NOT the words that are between parenthesis starting with uppercase and followed by lowercase e.g. '(Bobby)' or '(Bob went to the beach..)' --> This is the part I am struggling with.
text = ['(ABC went to the beach', 'The girl (ABC-2A) is walking', 'The dog (Bobby) is being walked', 'They are there (ABC)' ]
for string in text:
cleaned_acronyms = re.sub(r'\([A-Z]*\)?', '', string)
print(cleaned_acronyms)
#current output:
>> 'went to the beach' #Correct
>>'The girl -2A) is walking' #Not correct
>>'The dog obby) is being walked' #Not correct
>>'They are there' #Correct
#desired & correct output:
>> 'went to the beach'
>>'The girl is walking'
>>'The dog (Bobby) is being walked' #(Bobby) is NOT an acronym (uppercase+lowercase)
>>'They are there'