- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
JMP Academic Ambassador
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
Contains() and Substr()
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