cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
txwrangler
Level I

How to remove words from a column that occur before a certain phrase

I have a column with a variable number of words. Somewhere inside each row the phrase "my name is Spot" occurs. How can I remove all of the text that occurs prior to this phrase?

2 REPLIES 2

Re: How to remove words from a column that occur before a certain phrase

You can do this with a column formula containing a regular expression. See the attached example table for one that works for the situation you describe, and if you're new to regular expressions, I personally recommend the website https://regexr.com/. It's a good place to test different regular expressions to see if they're capturing the text you want, and it has a lot of nice hover help and quick references.

Ross Metusalem
JMP Academic Ambassador
Jeff_Perkinson
Community Manager Community Manager

Re: How to remove words from a column that occur before a certain phrase

@Ross_Metusalem is right, you can use a regular expression but, if you're like me and have never gotten the hang of them, you'll probably find that the character functions in JMP can give you most of the flexibility you need.

 

In this case, Contains() and Substr() work really well. If you want a case insensitive comparison you can use Lowercase() to get rid of the casing.

 

2022-12-09_16-56-41.208.png

Contains() and Substr()Contains() and Substr()

Lowercase()Lowercase()

 

Note that the -1 argument in Substr() means "to the end of the string".

 

@Craige_Hales has some good hints on the character string functions: JSL Character String Functions 

-Jeff