cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
David_Morrow
Level II

Extracting a particular string from a longer one

SourceTemperature
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_18392070

 

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

Re: Extracting a particular string from a longer one

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

 

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

View solution in original post

txnelson
Super User

Re: Extracting a particular string from a longer one

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;

position.PNG

Jim

View solution in original post

4 REPLIES 4

Re: Extracting a particular string from a longer one

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

 

Num( Regex( :Source, "-(-?\d\d?\d?)degc", "\1" ) )
David_Morrow
Level II

Re: Extracting a particular string from a longer one


Hi,
Thank you , that works and very succinct !

Kind Regards,
David.
txnelson
Super User

Re: Extracting a particular string from a longer one

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;

position.PNG

Jim
David_Morrow
Level II

Re: Extracting a particular string from a longer one

Thank you ,very helpful
Kind Regards,
David.

Recommended Articles