Nick Taylor
Nick Taylor

Reputation: 45

Remove parenthesis and text in parenthesis using REGEXREPLACE in Google Sheets

I have a cell containing a text string like this:

A1 = John (John started 1/1/2020)

I'd like to remove everything in parenthesis so the end result would be:

A1 = John

I am trying to use REGEXREPLACE and I have the following formula:

=REGEXREPLACE(A1,"\(([A-Za-z]+)\)","")

However, this is not working. How do I remove the parenthesis and everything inside? The text in the parenthesis will vary, but will always be inside parenthesis.

For additional context - The above formula does work on a cell with a text string like this:

A2 = William (Bill)

When I use the above formula on cell A2, I get this:

A2 = William

Why does it work on A2 but not A1?

Upvotes: 1

Views: 2124

Answers (2)

Josh Smith
Josh Smith

Reputation: 1

For anyone interested in being able to replace any number of sub-strings surrounded by parentheses, there's another posting here: Google sheets - How to remove ALL the parenthesis with text inside in a cell?

In that post, the regexreplace formula is used as follows:

=regexreplace(A1, "(\s\(.*?\))",)

to make a string like

we can (or can we...) replace multiple (try it) sub-strings with other text

become:

we can replace multiple sub-strings with other text

I was searching for this solution for a while, so I figured I'd post it here to make it that much easier to find.

Upvotes: 0

player0
player0

Reputation: 1

use:

=INDEX(IFNA(REGEXREPLACE(A1:A, " \((.+)\)", )))

enter image description here

Upvotes: 2

Related Questions