<?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: Extract string from name in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40107#M23478</link>
    <description>&lt;P&gt;You haven't provided an example of something with a W in it so that is untested. I think this will solve your problems:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;YourList = {"(GPN) CI-4/E7/DH-1 15S-40 L1807", "DEO (GPN) JD CI-4/E7/DH-1 5S-40 L1807", "(GPN) JD CI-4/E7/DH-1 40 L1807"};
Part1 = Part2 = {};
For(i=1,i&amp;lt;=N items(YourList),i++,
	SubWords = Words(YourList[i], " ");
	For(k=1,k&amp;lt;=N Items(SubWords),k++,
		If(contains(SubWords[k],"S")&amp;gt;0,
			Part1[i] = SubWords[k];
			k=N Items(SubWords)+1;
		)
	);
);
For(i=1,i&amp;lt;=N items(Part1),i++,
	If(contains(part1[i],"W")==0,
		Part2[i] = right(part1[i],2);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Jun 2017 13:29:56 GMT</pubDate>
    <dc:creator>pauldeen</dc:creator>
    <dc:date>2017-06-08T13:29:56Z</dc:date>
    <item>
      <title>Extract string from name</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40099#M23471</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to extract a string of data from a name. The position of the string varies in the name and the name has a variable number of sub-strings within it. An example is shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(GPN) CI-4/E7/DH-1 15S-40 L1807&amp;nbsp;&lt;BR /&gt;DEO (GPN) JD CI-4/E7/DH-1 5S-40 L1807&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(GPN) JD CI-4/E7/DH-1 40&amp;nbsp;L1807&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am interested in two parts: a string which contains the letter S (so in the examples, 15S-40 &amp;amp; 5S-40) AND if w is not present, I am interested in the numeric value.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is it possible to extract this using standard formula functions?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help would be great.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dipesh&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 10:50:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40099#M23471</guid>
      <dc:creator>Dipesh</dc:creator>
      <dc:date>2017-06-08T10:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from name</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40100#M23472</link>
      <description>&lt;P&gt;It appears that the component you want to strip off is the second to the last grouping. &amp;nbsp;If that is the case, then the code below will do that. &amp;nbsp;The Word() function is a very powerful function. &amp;nbsp;It's documentation can be found in either the Scripting Guide or the Scripting Index&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index==&amp;gt;Word&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "test",
	New Column( "String",
		character,
		values(
			{"(GPN) CI-4/E7/DH-1 15S-40 L1807", "DEO (GPN) JD CI-4/E7/DH-1 5S-40 L1807",
			"(GPN) JD CI-4/E7/DH-1 40 L1807"}
		)
	)
);
dt &amp;lt;&amp;lt; New Column( "Value", character, formula( Word( -2, :String, " " ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 11:44:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40100#M23472</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-08T11:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from name</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40101#M23473</link>
      <description>Hello,&lt;BR /&gt;Thanks for the reply.&lt;BR /&gt;&lt;BR /&gt;Unfortunately there is no commonality where the word I would like to extract is in the string - sometimes it is position 2 sometimes it is position 7!&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dipesh&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Jun 2017 11:58:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40101#M23473</guid>
      <dc:creator>Dipesh</dc:creator>
      <dc:date>2017-06-08T11:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from name</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40105#M23476</link>
      <description>&lt;P&gt;Using a Regular Expression you can match a 'space' followed by some characters until you hit an 'S-' then more characters until you hit the next 'space'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PAT = "(GPN) CI-4/E7/DH-1 15S-40 L1807";&lt;/P&gt;&lt;P&gt;x = regex(PAT,"\S+(?=S-).* ");&lt;BR /&gt;show(x);&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 13:13:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40105#M23476</guid>
      <dc:creator>thickey1</dc:creator>
      <dc:date>2017-06-08T13:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Extract string from name</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40107#M23478</link>
      <description>&lt;P&gt;You haven't provided an example of something with a W in it so that is untested. I think this will solve your problems:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;YourList = {"(GPN) CI-4/E7/DH-1 15S-40 L1807", "DEO (GPN) JD CI-4/E7/DH-1 5S-40 L1807", "(GPN) JD CI-4/E7/DH-1 40 L1807"};
Part1 = Part2 = {};
For(i=1,i&amp;lt;=N items(YourList),i++,
	SubWords = Words(YourList[i], " ");
	For(k=1,k&amp;lt;=N Items(SubWords),k++,
		If(contains(SubWords[k],"S")&amp;gt;0,
			Part1[i] = SubWords[k];
			k=N Items(SubWords)+1;
		)
	);
);
For(i=1,i&amp;lt;=N items(Part1),i++,
	If(contains(part1[i],"W")==0,
		Part2[i] = right(part1[i],2);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Jun 2017 13:29:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-string-from-name/m-p/40107#M23478</guid>
      <dc:creator>pauldeen</dc:creator>
      <dc:date>2017-06-08T13:29:56Z</dc:date>
    </item>
  </channel>
</rss>

