I want to update the following code to remove text inside parentheses if the text is not pure Arabic i.e. the text contains text in another language, such as English, etc.
def remove_text_between_parens(text):
n = 1 # run at least once
while n:
text, n = re.subn(r'\([^()]*\)', '', text) # remove non-nested/flat balanced parts
return text
For example:
input : (بالإنجليزية :YPFB) , (بالروسية: Противоселевая плотина Медео) , (Mother Mother), (Ганчи)
output: #text and parentheses should be removed
input : ( واي بي أف بي )
output : ( واي بي أف بي ) #the same as input, we keep text