<?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: Regex Extract numbers and decimals in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266815#M51976</link>
    <description>&lt;P&gt;Ouch!&lt;/P&gt;&lt;P&gt;Text explorer uses this pattern for numbers&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;([\-\+]? ?[\.,]?[0-9][\.,0-9]*( ?e ?[\-\+]? ?\d+)?)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;reading it from left to right&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;an optional + or -&lt;/LI&gt;&lt;LI&gt;an optional space&lt;/LI&gt;&lt;LI&gt;optional period or comma&lt;/LI&gt;&lt;LI&gt;a required digit&lt;/LI&gt;&lt;LI&gt;zero or more periods, commas, and digits&lt;/LI&gt;&lt;LI&gt;an optional exponent (with optional bits and pieces inside)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;the commas and periods are interchangeable because of different standards in various countries for how decimals and thousands separators are represented. There are some odd strings that could slip through that are not numbers, so you should write your code to expect the num() function might return a missing value.&lt;/P&gt;</description>
    <pubDate>Thu, 14 May 2020 21:50:35 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2020-05-14T21:50:35Z</dc:date>
    <item>
      <title>Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266761#M51963</link>
      <description>&lt;P&gt;I have a column and I need to extract the numbers from the strings in each row. The numbers could be decimals or not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using this formula:&amp;nbsp;&amp;nbsp;Regex( :PIPE_LENGTH, "[^(\d+\.\d+)]", "", globalreplace )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examples:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;String:&amp;nbsp; Length = 3.5".&amp;nbsp;Completed by John.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Expected: 3.5&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Actual: 3.5..&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example 2:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Completed for CEC. Pipe depth- 4.5" (MER)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Expected: 4.5&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Actual: .4.5()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why are the extra periods and parentheses coming in? Also, I am confused by the ^ at the beginning. When I remove it I get text only and not the numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 18:01:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266761#M51963</guid>
      <dc:creator>john_along</dc:creator>
      <dc:date>2020-05-14T18:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266778#M51968</link>
      <description>Looks [^(\d+\.\d+)] selects all but numbers, decimals and punctuation. which your are replacing with "". What is left are your numbers decimals and punctuation (). This expression is behaving the way I expect. I also tested it on your example and get the same result.&lt;BR /&gt;&lt;BR /&gt;Would something like this work?&lt;BR /&gt;Regex( :PipeLength, "(\d+.\d+)", "\1" )&lt;BR /&gt;&lt;BR /&gt;Not sure what the rest of your data look like but this expression is plucking out only the numbers and decimals you need. It worked on both of your examples.</description>
      <pubDate>Thu, 14 May 2020 18:54:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266778#M51968</guid>
      <dc:creator>Jason_Wiggins</dc:creator>
      <dc:date>2020-05-14T18:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266790#M51970</link>
      <description>&lt;P&gt;This is better. I do have a scenario such as:&lt;/P&gt;&lt;P&gt;John cut 5"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does not have decimal. Your example is returning blank.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 19:02:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266790#M51970</guid>
      <dc:creator>john_along</dc:creator>
      <dc:date>2020-05-14T19:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266794#M51971</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Regex( PIPE_LENGTH, "\D*(\d+\.?\d*)\D*", "\1" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 May 2020 19:09:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266794#M51971</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-05-14T19:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266800#M51974</link>
      <description>Perfect. Thanks for the quick help on a stumper for me.</description>
      <pubDate>Thu, 14 May 2020 19:25:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266800#M51974</guid>
      <dc:creator>john_along</dc:creator>
      <dc:date>2020-05-14T19:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266808#M51975</link>
      <description>&lt;P&gt;I thought of another case: "Mark cut off .5" of his finger." I am stuck! I can't get my regex to work with this case and the others. Its one set of cases or the other!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using look ahead...&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 );

PIPE_LENGTH = "Length = 3.5\!". Completed by John.";

PIPE_LENGTH = "Completed for CEC. Pipe depth- 4.5\!" (MER)";

PIPE_LENGTH = "John cut 5\!"";

PIPE_LENGTH = "Mark cut .5\!" off his finger.";
Regex( PIPE_LENGTH, "\D*(?=\.)?(\d*\.?\d*)\D*", "\1" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if using JMP Patterns would be easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/982"&gt;@Craige_Hales&lt;/a&gt;&amp;nbsp;, where are you???&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 20:31:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266808#M51975</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2020-05-14T20:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Extract numbers and decimals</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266815#M51976</link>
      <description>&lt;P&gt;Ouch!&lt;/P&gt;&lt;P&gt;Text explorer uses this pattern for numbers&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;([\-\+]? ?[\.,]?[0-9][\.,0-9]*( ?e ?[\-\+]? ?\d+)?)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;reading it from left to right&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;an optional + or -&lt;/LI&gt;&lt;LI&gt;an optional space&lt;/LI&gt;&lt;LI&gt;optional period or comma&lt;/LI&gt;&lt;LI&gt;a required digit&lt;/LI&gt;&lt;LI&gt;zero or more periods, commas, and digits&lt;/LI&gt;&lt;LI&gt;an optional exponent (with optional bits and pieces inside)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;the commas and periods are interchangeable because of different standards in various countries for how decimals and thousands separators are represented. There are some odd strings that could slip through that are not numbers, so you should write your code to expect the num() function might return a missing value.&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2020 21:50:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-Extract-numbers-and-decimals/m-p/266815#M51976</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-05-14T21:50:35Z</dc:date>
    </item>
  </channel>
</rss>

