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
- :
- Extracting a particular string from a longer one

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

Highlighted

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

Nov 7, 2018 6:22 AM
(3751 views)

Source | Temperature |

MZ_ES20-ATF786_D03-R_8x8-5hz_NoCG_0klux-black3--5degc__20181105_203705 | -5 |

MZ_ES20-ATF786_D03-R_8x8-5hz_NoCG_0klux-grey17--30degc__20181105_194659 | -30 |

MZ_ES20-ATF786_D03-R_8x8-5hz_NoCG_0klux-white64-70degc__20181105_183920 | 70 |

Hi,

I am trying to extract the temperature from the "Source" column in the JMP table above using JSL

In the Temperature column I have written the results that I would like. My problem is that the delimiter between the colour

(black3,grey17 and white64) and the temperature is a dash "-" but sometimes the temperature is negative which is also "-"

I have tried a number of things with the Word function but so far to no avail. Any help with this would be apprecated.

Thanks and regards,

David

2 ACCEPTED SOLUTIONS

Accepted Solutions

Highlighted

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

Created:
Nov 7, 2018 6:44 AM
| Last Modified: Nov 7, 2018 6:52 AM
(3748 views)
| Posted in reply to message from David_Morrow 11-07-2018

This problem is easily solved by the Regex() string function. Try this:

`Num( Regex( :Source, "-(-?\d\d?\d?)degc", "\1" ) )`

Learn it once, use it forever!

Highlighted

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

Here is a formula that I believe will do the trick

```
degCPosition = Contains( :Source, "degc__" ) - 1;
i = degCPosition;
While( Substr( :Source, i, 1 ) != "-", i-- );
If( Substr( :Source, i - 1, 1 ) == "-",
result = Num( Substr( :Source, i, (degCPosition - i) + 1 ) ),
result = Num( Substr( :Source, i + 1, degCPosition - i ) )
);
result;
```

Jim

4 REPLIES 4

Highlighted

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

Created:
Nov 7, 2018 6:44 AM
| Last Modified: Nov 7, 2018 6:52 AM
(3749 views)
| Posted in reply to message from David_Morrow 11-07-2018

This problem is easily solved by the Regex() string function. Try this:

`Num( Regex( :Source, "-(-?\d\d?\d?)degc", "\1" ) )`

Learn it once, use it forever!

Highlighted
##

Hi,

Thank you , that works and very succinct !

Kind Regards,

David.

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

Re: Extracting a particular string from a longer one

Hi,

Thank you , that works and very succinct !

Kind Regards,

David.

Highlighted

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

Here is a formula that I believe will do the trick

```
degCPosition = Contains( :Source, "degc__" ) - 1;
i = degCPosition;
While( Substr( :Source, i, 1 ) != "-", i-- );
If( Substr( :Source, i - 1, 1 ) == "-",
result = Num( Substr( :Source, i, (degCPosition - i) + 1 ) ),
result = Num( Substr( :Source, i + 1, degCPosition - i ) )
);
result;
```

Jim

Highlighted
##

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

Re: Extracting a particular string from a longer one

Thank you ,very helpful

Kind Regards,

David.

Kind Regards,

David.

Article Labels

There are no labels assigned to this post.