<?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 numbers from strings of unequal sizes in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268559#M52273</link>
    <description>&lt;P&gt;Yet another way - try the words function.&amp;nbsp; This is the column formula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;look_for = {"abcde", "fghij", "klmno"};
wlist = Words( :Column 1, " " );
one_num = .;
For( i = 1, i &amp;lt;= N Items( look_for ), i++,
	one_word = look_for[i];
	f = Contains( wlist, one_word );
	If( f,
		one_num = Num( wlist[f + 1] );
		Break();
	);
);
one_num;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 22 May 2020 20:27:17 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2020-05-22T20:27:17Z</dc:date>
    <item>
      <title>Extract numbers from strings of unequal sizes</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268448#M52262</link>
      <description>&lt;P&gt;I have a column of&amp;nbsp;strings with embedded numbers. I know how to determine if these strings contains the correct text I am looking for, but not how to extract the values that come after each of these. If the string sizes were equal, I could just use the munger function based on the location, but this cannot be done since string size is not consistent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E.g "The fix in is abcde +0.2, there is more text here fghij -1."&lt;/P&gt;&lt;P&gt;I want to query for "abcde" and "fghij" and extract the +0.2 and -1 respective values in the space right after the strings appear. There is usually a space followed by a +/- and a number (whole numbers and decimals out to one decimal place as shown above).&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 18:12:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268448#M52262</guid>
      <dc:creator>dcietek</dc:creator>
      <dc:date>2020-05-22T18:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from strings of unequal sizes</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268456#M52264</link>
      <description>&lt;P&gt;Check out the Word() function.&amp;nbsp; Given the examples you gave, one could simply look for the the 2nd word in the string, based upon finding a blank&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Word(2, &amp;lt;your string column&amp;gt;, " " )&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;You can Contains() to find a "+" or "-" and from there, substr() the string to get the numeric value&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attached is the below data table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thenum.PNG" style="width: 645px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/24138i493F6A1B40BC5BFA/image-size/large?v=v2&amp;amp;px=999" role="button" title="thenum.PNG" alt="thenum.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 18:43:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268456#M52264</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-22T18:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from strings of unequal sizes</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268505#M52266</link>
      <description>&lt;P&gt;You can also use the&amp;nbsp;&lt;STRONG&gt;Regex()&lt;/STRONG&gt; function with regular expressions in a column formula. That approach might help if the example you gave does not show all the possible conditions. This is a script to illustrate the idea.&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 );

text = "The fix in is abcde +0.2, there is more text here fghij -1.";

answer 1 = Num( Regex( text, ".*abcde ([-+]?\d?.?\d?)", "\1" ) );

answer 2 = Num( Regex( text, ".*fghij ([-+]?\d?.?\d?)", "\1" ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;EM&gt;text&lt;/EM&gt; variable in the script represents the current row for a column formula. The &lt;EM&gt;answer 1&lt;/EM&gt; would be the result in the same row of the first new result column. You use the expression to the right of the equal sign for the formula.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This example is simple. It would need to be extended and refined if the nature of the text or the preface to the numbers were more complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also have JMP Patterns for matching, returning, and substituting character strings.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 19:14:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268505#M52266</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-05-22T19:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from strings of unequal sizes</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268559#M52273</link>
      <description>&lt;P&gt;Yet another way - try the words function.&amp;nbsp; This is the column formula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;look_for = {"abcde", "fghij", "klmno"};
wlist = Words( :Column 1, " " );
one_num = .;
For( i = 1, i &amp;lt;= N Items( look_for ), i++,
	one_word = look_for[i];
	f = Contains( wlist, one_word );
	If( f,
		one_num = Num( wlist[f + 1] );
		Break();
	);
);
one_num;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 May 2020 20:27:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-strings-of-unequal-sizes/m-p/268559#M52273</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2020-05-22T20:27:17Z</dc:date>
    </item>
  </channel>
</rss>

