cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

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

getting a string from a list, where string contains defined text

Hi,

 

can someone help me please? I have created a list that looks something like that:

{"C1234_here_is_some_text", "C1235_here_is_some_other_text", "C1236_you_get_the_idea", ..., "C2000_still_dont_ends_here"}

I want to get the complete string of the list where the first part of the string (e.g. "C1234") is "C1999".

Whats the correct code here?

Thank you in advance

 

1 REPLY 1
txnelson
Super User

Re: getting a string from a list, where string contains defined text

This is how I would do it

Names Default To Here( 1 );
x = {"C1234_here_is_some_text", "C1235_here_is_some_other_text", "C1236_you_get_the_idea", ..., "C2000_still_dont_ends_here"};

found = "Not Found";
For( i = 1, i <= N Items( x ), i++,
	If( Contains( x[i], "C1999" ) == 1,
		found = x[i];
		Break()
	)
);
show(found);
Jim

Recommended Articles