cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
paulp
Level III

select text between delimiters

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 1
ms
Super User (Alumni) ms
Super User (Alumni)

Re: select text between delimiters

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()