<?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 string in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579135#M78646</link>
    <description>&lt;P&gt;Here is a simple example that reads in your sample data table and produces a list with the values&lt;/P&gt;
&lt;PRE&gt;x = {"52", "79", "39", "41", "43", "38", "40", "42", "1"};&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = current data table();
x = {};
For Each Row(
	If( :values != "",
		y = Eval( Parse( :values ) );
		For Each( {value}, y, Insert Into( x, Char( value ) ) );
	)
);

Show( x );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Dec 2022 22:34:53 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-12-08T22:34:53Z</dc:date>
    <item>
      <title>Extract numbers from string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579120#M78645</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to extract all the numbers contain in [] and store in the list. Is there a way to achieve this with jsl?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to extract numbers from the column and store in the list which should look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;bins = {"52","79","39 41 43", "38 40 42", "1"};&lt;/P&gt;&lt;P&gt;Any advice would be much helpful.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jacksmith12_0-1670537130464.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/48065i89988B56978C62F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1670537130464.png" alt="Jacksmith12_0-1670537130464.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:04:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579120#M78645</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T16:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579135#M78646</link>
      <description>&lt;P&gt;Here is a simple example that reads in your sample data table and produces a list with the values&lt;/P&gt;
&lt;PRE&gt;x = {"52", "79", "39", "41", "43", "38", "40", "42", "1"};&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = current data table();
x = {};
For Each Row(
	If( :values != "",
		y = Eval( Parse( :values ) );
		For Each( {value}, y, Insert Into( x, Char( value ) ) );
	)
);

Show( x );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2022 22:34:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579135#M78646</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-12-08T22:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579142#M78647</link>
      <description>&lt;P&gt;There are a couple of different ways to do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the values for your Values column into a list using the &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/column-messages.shtml#ww1922141" target="_blank" rel="noopener"&gt;&amp;lt;&amp;lt;Get Values() message&lt;/A&gt; to the column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to get rid of the missing values from that list. It's easy to do this by locating the missing rows in the data table with &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/data-table-messages.shtml#ww1901136" target="_blank" rel="noopener"&gt;Get Rows Where()&lt;/A&gt;. Then the &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/list-functions.shtml#ww2484894" target="_blank" rel="noopener"&gt;Remove From()&lt;/A&gt; function will remove those elements from the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use For Each() and the Word() function to get rid of the square brackets (i.e., "[]").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Data Table( "Sample.jmp" );

//locate the missing values
missings = dt &amp;lt;&amp;lt; get rows where( Is Missing( :values ) );

//get a list of the Values column
lst = :Values &amp;lt;&amp;lt; get values;

//Remove the missings from the list
Remove From( lst, As List( missings ) );

//strip the square brackets
For Each( {item, i}, lst, lst[i] = Word( 1, item, "[]" ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also do all this in the data table by adding a new formula column with the Word() function to strip the square brackets and then getting the values from the new column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=Data Table("Sample.jmp");
new_col = dt &amp;lt;&amp;lt; New Column( "New Values", Character,
	formula( Word( 1, :Values, "[]" ) )
);
lst = (new_col &amp;lt;&amp;lt; get values)[dt &amp;lt;&amp;lt;
get rows where( !Is Missing( :New Values ) )];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;The Word() function is my favorite:&amp;nbsp;&lt;LI-MESSAGE title="If you learn only one Formula Editor function, Word() is the one" uid="30381" url="https://community.jmp.com/t5/JMP-Blog/If-you-learn-only-one-Formula-Editor-function-Word-is-the-one/m-p/30381#U30381" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-blog-thread lia-fa-icon lia-fa-blog lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2022 23:18:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579142#M78647</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2022-12-08T23:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579321#M78659</link>
      <description>&lt;P&gt;Thanks Jim :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2022 13:54:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579321#M78659</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2022-12-09T13:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579474#M78670</link>
      <description>&lt;P&gt;Here is another approach. There is a lot of capability for processing strings, lists, and data columns in JMP!&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 );'

// create sample
dt = New Table( "Sample",
	New Column( "Values", "Character", "Nominal",
		Values( { "", "", "[52]", "[79]", "[39 41 43]", "[38 40 42]", "", "", "", "[1]" } )
	)
);

// use sample
val = :Values &amp;lt;&amp;lt; Get Values;

// find 
bins = List();

For( i = 1, i &amp;lt;= N Items( val ), i++,
	If( val[i] != "",
		Insert Into( bins,
			Substitute( val[i],
				"[", "",
				"]", ""
			);
		);
	);
);

Show( bins );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Dec 2022 17:11:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string/m-p/579474#M78670</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2022-12-09T17:11:07Z</dc:date>
    </item>
  </channel>
</rss>

