cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

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

Find location of item in a list that partially matched to a string (search list by partial match)

Can't find a good way of doing this task.

Let's say I have this:

list = {"big apple", "big orange", "big pear"};
string = "orange";

How do I find a location of an item in the list that partially matches to the string?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Find location of item in a list that partially matched to a string (search list by partial match)

Here is one way

Names Default To Here( 1 );
thelist = {"big apple", "big orange", "big pear"};
string = "orange";

found = 0;
For( i = 1, i <= N Items( thelist ), i++,
	If( Contains( thelist[i], string ),
		found = i;
		Break();
	)
);
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Find location of item in a list that partially matched to a string (search list by partial match)

Here is one way

Names Default To Here( 1 );
thelist = {"big apple", "big orange", "big pear"};
string = "orange";

found = 0;
For( i = 1, i <= N Items( thelist ), i++,
	If( Contains( thelist[i], string ),
		found = i;
		Break();
	)
);
Jim
miguello
Level VII

Re: Find location of item in a list that partially matched to a string (search list by partial match)

Ok, I was hoping that there would be a solution without iteration.

Something in one line that would either give me  the location mask (like {0, 1, 0} for the case above) or the list of locations (like {2} for the case above)

 

Recommended Articles