For example i have this in the G33 cell:
Hello (example) world (example 2). How are you (example 3) ?
And i want to remove ALL of the 3 parenthesis with their texts so it becomes:
Hello world. How are you?
I have found some functions but they only remove the first parenthesis.
I want a function that will remove every parenthesis with their contents that exists on a cell.
Can someone provide me with one? I am a begginer in google sheets so my knowledge on functions is very restricted. so please help me
CodePudding user response:
See if this helps
=regexreplace(G33, "(\s\(.*?\))",)
CodePudding user response:
This is sufficient to remove a single level of parenthesis:
=regexreplace(A1,"\([^()]*\)","")
Replacing nested brackets appears challenging, but as a workaround you can nest the function to arbitrary depth like this:
=regexreplace(regexreplace(A1,"\([^()]*\)",""),"\([^()]*\)","")
This assumes that the brackets are correctly matched. You could run a quick check like this:
=len(substitute(A1,"(",""))=len(substitute(A1,")",""))
which at least checks that you have as many right brackets as left ones, but again checking that they are correctly matched would be more difficult.