stillLearning
stillLearning

Reputation: 21

Regex RE2: Extract text inside brackets at the end of a string including brackets and only the last set if more than one

I'm using Google Sheets, which uses RE2 syntax. All my data has brackets at the end of the string with numbers and sometimes other characters also. Some rows have more than one set of brackets with something in there. I only want to remove the last set of brackets and the content between

If I have:

This is a bit random (2019)(861.01)

Then I want to return:

This is a bit random (2019)

and if I have:

This is a bit random (861.01)

I want to return:

This is a bit random

Any assistance would be greatly appreciated!

Upvotes: 0

Views: 1006

Answers (2)

player0
player0

Reputation: 1

if you dont want to use TRIM try:

=ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(A2:A, "\(([^)]*)\)[^(]*$", ), " $", ))

enter image description here

Upvotes: 1

Rocky
Rocky

Reputation: 990

Try below formula:

=REGEXREPLACE(A1,"\(([^)]*)\)[^(]*$","")

Upvotes: 1

Related Questions