<?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 Regex convert text to numbers in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782294#M96553</link>
    <description>&lt;P&gt;I have a property listed in a column (Device in this case) that contains a string.&amp;nbsp; Somewhere inside the string is a reference to a numeric value that I need to extract and convert to an actual number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula below works but it seems like this could be done in a much simpler way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex( Substr( :Device, 6 ), "K", "000", GLOBALREPLACE )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any instance of 1K is replaced by 1000 in this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Slán&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SpannerHead&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2024 18:51:50 GMT</pubDate>
    <dc:creator>SpannerHead</dc:creator>
    <dc:date>2024-08-16T18:51:50Z</dc:date>
    <item>
      <title>Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782294#M96553</link>
      <description>&lt;P&gt;I have a property listed in a column (Device in this case) that contains a string.&amp;nbsp; Somewhere inside the string is a reference to a numeric value that I need to extract and convert to an actual number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The formula below works but it seems like this could be done in a much simpler way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex( Substr( :Device, 6 ), "K", "000", GLOBALREPLACE )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any instance of 1K is replaced by 1000 in this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Slán&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SpannerHead&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 18:51:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782294#M96553</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-08-16T18:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782305#M96554</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;this could be done in a much simpler way&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you consider to be this much simpler?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 19:05:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782305#M96554</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-16T19:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782306#M96555</link>
      <description>&lt;P&gt;Jarmo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Num( Regex( :Device, "(\d+)K", "\1" ) ) * 1000&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Slán&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SpannerHead&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 19:15:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782306#M96555</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-08-16T19:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782308#M96556</link>
      <description>&lt;P&gt;So... use that...? These are highly specific to your data and application (for example usually "k" would be &lt;A href="https://en.wikipedia.org/wiki/Kilo-" target="_blank" rel="noopener"&gt;kilo&lt;/A&gt; not "K")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have to fix numbers written as strings into numbers, I would say there is never a&amp;nbsp; single simple solution for that (good example could be excel, it just assumes something and totally ruins your data in irreversible way).&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 19:24:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782308#M96556</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-08-16T19:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782313#M96558</link>
      <description>&lt;P&gt;Here is a simple Example using JSL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt = New Table( "example",
	Add Rows( 2 ),
	New Column( "val", Character, "Nominal", Set Values( {"1K", "5K"} ) )
);
wait(5);

// Convert the values
for each row(
	:val = Substitute(:val,"K","000")
);
wait(0);&lt;BR /&gt;&lt;BR /&gt;// Change column to numeric
dt:val &amp;lt;&amp;lt; data type(numeric)&amp;lt;&amp;lt;modeling type(continuous)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Aug 2024 19:37:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782313#M96558</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-08-16T19:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex convert text to numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782315#M96559</link>
      <description>&lt;P&gt;Jarmo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of these things work and you're right, my problem is very specific, that can happen to people sometimes.&amp;nbsp; The solution I referenced gets a spanner in the works if there is more than one letter K (defaults to capitals in my standard data output) in my data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks anyway&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Slán&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SpannerHead&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 20:16:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-convert-text-to-numbers/m-p/782315#M96559</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-08-16T20:16:44Z</dc:date>
    </item>
  </channel>
</rss>

