It’s World Statistics Day! To honor the theme of the day, the JMP User Community is having conversations about the importance of trust in statistics and data. And we want to hear from you! Tell us the steps you take to ensure that your data is trustworthy.
Choose Language Hide Translation Bar
Highlighted
paulp
Level II

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
Highlighted
ms
Super User ms
Super User

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

Article Labels

    There are no labels assigned to this post.