<?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 JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string-in-JSL/m-p/15945#M14566</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This could be simpler if you know the numbers are unsigned integers and there is only one number in the string.&amp;nbsp; This example assumes there isn't any scientific notation but there might be commas between numbers.&amp;nbsp; It also assumes there are no numbers in a unit, like sec^2.&amp;nbsp; the regex function is used to remove all the characters that are not (the ^ is "not") in the set 0-9, minus, period, and comma.&amp;nbsp; the backslash before the minus is an escape to make not be part of a range.&amp;nbsp; The "" is the replacement value for each character not in the set (deleting them).&amp;nbsp; The words function turns the result into a list of strings using the comma as a delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teststring = "weight=-4.8gm,speed=13m/h";&lt;/P&gt;&lt;P&gt;words(regex(teststring, "[^0-9\-.,]","",GLOBALREPLACE),",");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"-4.8", "13"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for the simple case (with lots of potential problems) where \D means "not a digit" and the num() function turns the string into a number,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teststring = "48gm";&lt;/P&gt;&lt;P&gt;num(regex(teststring, "\D","",GLOBALREPLACE));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;48&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Dec 2015 13:56:09 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2015-12-16T13:56:09Z</dc:date>
    <item>
      <title>Extract numbers from string in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string-in-JSL/m-p/15944#M14565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have string containing numbers, letters and symbols. I would like to extract only numbers. &lt;/P&gt;&lt;P&gt;For example "48mg/l" becomes 48, "24" remains 24, etc. &lt;/P&gt;&lt;P&gt;It has to be done in JSL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 11:40:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string-in-JSL/m-p/15944#M14565</guid>
      <dc:creator>percevalsondag0</dc:creator>
      <dc:date>2015-12-16T11:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract numbers from string in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string-in-JSL/m-p/15945#M14566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This could be simpler if you know the numbers are unsigned integers and there is only one number in the string.&amp;nbsp; This example assumes there isn't any scientific notation but there might be commas between numbers.&amp;nbsp; It also assumes there are no numbers in a unit, like sec^2.&amp;nbsp; the regex function is used to remove all the characters that are not (the ^ is "not") in the set 0-9, minus, period, and comma.&amp;nbsp; the backslash before the minus is an escape to make not be part of a range.&amp;nbsp; The "" is the replacement value for each character not in the set (deleting them).&amp;nbsp; The words function turns the result into a list of strings using the comma as a delimiter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teststring = "weight=-4.8gm,speed=13m/h";&lt;/P&gt;&lt;P&gt;words(regex(teststring, "[^0-9\-.,]","",GLOBALREPLACE),",");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{"-4.8", "13"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for the simple case (with lots of potential problems) where \D means "not a digit" and the num() function turns the string into a number,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teststring = "48gm";&lt;/P&gt;&lt;P&gt;num(regex(teststring, "\D","",GLOBALREPLACE));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;48&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Dec 2015 13:56:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-numbers-from-string-in-JSL/m-p/15945#M14566</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2015-12-16T13:56:09Z</dc:date>
    </item>
  </channel>
</rss>

