0

Have several cells in a column that at the end of the sentence have a sentence inside of ( )

Ex. Hello World (wwfx fgty jkilo)

The output desire is Hello World ()

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
Chapin
  • 31
  • 1
  • 2

2 Answers2

0

You can use 'match' to do this. The awkward bit is making sure you deal with both the situation where there are brackets and where there are not brackets successfully.

Using match:

with(value.match(/(.*)\(.*\)/)[0],w,if(isNonBlank(w),w+"()",value))

This extracts everything before the last open bracket in the string. If there is no open bracket then it just uses the original value

Owen Stephens
  • 1,550
  • 1
  • 8
  • 10
0

The answer without using regex:

  1. create a text filter searching for (
  2. create a text filter searching for )
  3. use the following GREL value.split('(')[0]+'()'+value.split(')')[-1]

where

  • value.split('(')[0] selects everything before the first (
  • value.split(')')[-1] selects everything after the last ) +'()'+
  • concatenate the two results and add the ()
magdmartin
  • 1,712
  • 3
  • 20
  • 43