<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding values in a list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53816#M30403</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11322"&gt;@Aam_jmp&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;You can use Regex to find the string you want. Your search term needs to be constructed to cover as wide a range as you want to look for and the power of regular expressions gets unlocked by how well you can construct your search term.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example below covers the search only for the term "Henry"&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Log(); Clear Globals(); 

MyList = List = {Henry(1,2), Robert(3,4), John( . ,6), Kai(13, . ) };
SelInd = {};

for(i = 1, i &amp;lt;= N Items(MyList), i++,
		If(!IsMissing(Regex(Char(MyList[i]),"Henry")),
			Insert Into(SelInd,i);
		  );
   );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 25 Mar 2018 16:25:09 GMT</pubDate>
    <dc:creator>uday_guntupalli</dc:creator>
    <dc:date>2018-03-25T16:25:09Z</dc:date>
    <item>
      <title>Finding values in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53810#M30398</link>
      <description>&lt;P&gt;If I have a list:&lt;/P&gt;&lt;P&gt;List = {Henry(1,2), Robert(3,4), John( . ,6), Kai(13, . ) };&lt;/P&gt;&lt;P&gt;But the position of names is always different for different tables,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;List = {Henry(1,2), Robert(3,4),&amp;nbsp; Kai(13, . ), John( . ,6) };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and sometimes certain names are missing too.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;List = {Henry(1,2), Robert(3,4) };&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I know we can use Contains(List, List[1]) but that way, we consider the position of values in a list. I want to know of there is any way I can search for strings like, "Henry" and extract (1,2) for Henry, and save 1 as one variable and 2 as another. Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 25 Mar 2018 13:21:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53810#M30398</guid>
      <dc:creator>Aam_jmp</dc:creator>
      <dc:date>2018-03-25T13:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding values in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53816#M30403</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11322"&gt;@Aam_jmp&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;You can use Regex to find the string you want. Your search term needs to be constructed to cover as wide a range as you want to look for and the power of regular expressions gets unlocked by how well you can construct your search term.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The example below covers the search only for the term "Henry"&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Log(); Clear Globals(); 

MyList = List = {Henry(1,2), Robert(3,4), John( . ,6), Kai(13, . ) };
SelInd = {};

for(i = 1, i &amp;lt;= N Items(MyList), i++,
		If(!IsMissing(Regex(Char(MyList[i]),"Henry")),
			Insert Into(SelInd,i);
		  );
   );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Mar 2018 16:25:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53816#M30403</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2018-03-25T16:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Finding values in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53854#M30423</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11322"&gt;@Aam_jmp&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Following up on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6696"&gt;@uday_guntupalli&lt;/a&gt;'s suggestion to use regular expressions, here's a simple script using Contains() that will work similarly and store the values in var1 and var2.&amp;nbsp; The variable "found" is used to exit the loop early if the name is found, or print a message that the search string was not found in the list while setting var1 and var2 to missing.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;search_str = "Henry";

found = 0;
for(i = 1, i &amp;lt;= N Items(MyList), i++,
	temp = char(MyList[i]);
	If(Contains(temp,search_str) &amp;gt; 0,
		var1 = num(word(2,temp,"(),"));
		var2 = num(word(3,temp,"(),"));
		found = 1;
	);
	if(found, break());
	if(i == N Items(MyList) &amp;amp; !found, 
		Print("Search term not found in the list.");
		var1 = .;
		var2 = .;	
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 16:46:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53854#M30423</guid>
      <dc:creator>cwillden</dc:creator>
      <dc:date>2018-03-26T16:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding values in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53855#M30424</link>
      <description>&lt;P&gt;This should do what you want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to here(1);
Extract Expr({Henry(1,2), Robert(3,4), John( . ,6), Kai(13, . ) }, Henry(Wild(), Wild()));

//or for a more complete answer
l = {Henry(1,2), Robert(3,4), John( . ,6), Kai(13, . ) };
extracted = Eval(Substitute(
	Expr(
		Extract Expr(DV_LIST, Henry(WildList()));
	), 
	Expr(DV_LIST), nameexpr(l)
));

first = Arg(extracted, 1);
second = Arg(extracted, 2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 17:06:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53855#M30424</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2018-03-26T17:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Finding values in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53865#M30427</link>
      <description>&lt;P&gt;Hey, thank you I made it work using regex though.&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2610"&gt;@vince_faller&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 19:00:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Finding-values-in-a-list/m-p/53865#M30427</guid>
      <dc:creator>Aam_jmp</dc:creator>
      <dc:date>2018-03-26T19:00:50Z</dc:date>
    </item>
  </channel>
</rss>

