Subscribe Bookmark RSS Feed

select text between delimiters

paulp

Community Trekker

Joined:

Jun 30, 2011

Hello,  I'm trying to write a formula to select text that lies between the delimiters [ ].

All text in my column appears as below:

RinseAid[Apex.Rinse]*(Temp-130)

RinseAid[AutoDri]*(Temp-130)

RinseAid[Bright&Dry]*(Temp-130)

RinseAid[Clarity]*(Temp-130)

...

I want to keep only the text between the [ ] symbols:

Apex.Rinse

AutoDri

Bright&Dry

Clarity

But using a formula such as below, Iget a mesage that the formula requires a character

Starts With( :Term, "[" ),

Any ideas?  thanks, Paul


1 REPLY
ms

Super User

Joined:

Jun 23, 2011

Starts with() returns 0 or 1.  If that is part of a formula that require character argument, that could explain the error message. However, Starts with() alone would not give that error if :Term is a character column.

In this case,  the Word() function should work.

Paste this into a column formula

Word( 2, :Term, "[]" )

Or if you want to replace the values in the :Term column, try running this script (assumes there is always some text before "[")

For Each Row( :Term = Word( 2, :Term, "[]" ) );


Regex() can also be used and allows a more fool-proof search. However, here it requires some extra effort since \[ and \] have special but different meaning in jsl and grep.

But this should work:

regex(:Term,"\[\[(.+?)\]\]","\1");

Message was edited by: Marcus Sundbom
Added Regex()