Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- String parsing formula

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 12, 2018 3:10 AM
(2017 views)

Hello,

How can I define formula to import the __right__ srting after the __last__ "_"?

For example:

Column1 | Formula |

CONTINUITY_P_TXP_POS_400UA_TI1310P | TI1310P |

CONTINUITY_DIG_NEG_2MA_CCLK | CCLK |

Thaks in advance!

Assaf

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 12, 2018 5:25 AM
(2874 views)
| Posted in reply to message from uday_guntupalli 02/12/2018 07:38 AM

**Words** will get you there. This formula will do the trick:

```
c = Words(:Column 1, "_");
d = c[N Items(c)];
```

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: String parsing formula

@Assaf1,

Do you need the formula to be in a table ? I can offer the following solution that works :

```
dt = Current Data Table(); // Ensure your data table is open and it is current
Vals = :Column 1 << Get Values; // Get Values out
Res = List(); // Define empty list
for(i = 1 , i <= N Items(Vals), i++,
Test = Words(Vals[i],"_"); // Words is the function that will split your string by delimiter
Insert Into(Res,Test[N Items(Test)]);
);
Show(Res);
```

Alternatively,

You could use a similar approach to parse out the strings separated by the delimiter in a column formula as well, by using the following as a column formula:

`Words(:Column 1, "_")`

But then, I can't really think of a way to get the last string out in the column formula. Hope this helps some. Maybe look at "Substr" function - it might help

Best

Uday

Uday

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 12, 2018 5:25 AM
(2875 views)
| Posted in reply to message from uday_guntupalli 02/12/2018 07:38 AM

**Words** will get you there. This formula will do the trick:

```
c = Words(:Column 1, "_");
d = c[N Items(c)];
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: String parsing formula

Thanks a lot for your suport

It's work!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: String parsing formula

Similarly, you could use the Word function to get the last "word" using an index of -1 (i.e. count backwards from the end). This just saves you from needing any JSL variables/lists.

`Word( -1, :Column 1, "_"); `

Justin

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: String parsing formula

Feb 12, 2018 7:25 AM
(1972 views)
| Posted in reply to message from Justin_Chilton 02/12/2018 09:59 AM

JSL continues to surprise me! Great solution Justin.