cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
ReliabilityWolf
Level III

search substring from vareity of string

I have a column with name of failure, which contains all variety of strings. I like to search error code with start of "ex". the error code is 10-character string with start of "ex". and put the 1st error code into column of "1st code", all error codes into column of "all codes. what formula is set to both columns? sorry to bother again. I need to quickly make my work in hands closed firstly, then take time to learn JMP help document. 

ReliabilityWolf_0-1724685518572.png

 

2 REPLIES 2
jthi
Super User

Re: search substring from vareity of string

txnelson
Super User

Re: search substring from vareity of string

Here is one way to create these 2 columns

Formula for :fst code

start = contains(:Failure,"0x");
if(start>0,substr(:Failure,start,start+10),"");

Formula for :All Codes

theCodes = {};;
theString = :Failure;
While( Contains( theString, "0x" ) > 0,
	start = Contains( theString, "0x" );
	Insert Into( theCodes, Substr( theString, start, start + 10 ) );
	theString = Substr( theString, start + 10 );
);
concat items(theCodes, ",");
Jim