<?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 Splitting a string to extract numbers in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518525#M74458</link>
    <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a string that is character and I want to extract a 4 number section. The position of the numbers may change&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the string may be&lt;/P&gt;&lt;P&gt;value ="Hello 0123 example";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this but only works if the numbers are in the correct position.&amp;nbsp;&lt;/P&gt;&lt;P&gt;value ="Hello 0123 example";&lt;/P&gt;&lt;P&gt;extract=substr(value,7, 4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the position of the number will change how can I extract this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 17:03:38 GMT</pubDate>
    <dc:creator>B1234</dc:creator>
    <dc:date>2023-06-09T17:03:38Z</dc:date>
    <item>
      <title>Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518525#M74458</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a string that is character and I want to extract a 4 number section. The position of the numbers may change&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the string may be&lt;/P&gt;&lt;P&gt;value ="Hello 0123 example";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried this but only works if the numbers are in the correct position.&amp;nbsp;&lt;/P&gt;&lt;P&gt;value ="Hello 0123 example";&lt;/P&gt;&lt;P&gt;extract=substr(value,7, 4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the position of the number will change how can I extract this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:03:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518525#M74458</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2023-06-09T17:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518561#M74462</link>
      <description>&lt;P&gt;You could try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

string = "Hello 0123 example";
matches = Regex Match(
	string,
	"[0-9]{4}",
);
// ASSUMES that you are interested only in the first 4-digit number, if there is more than one
extractedNumber = matches[1];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This returns "0123".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that it still returns "0123" if your input string is "Hello 01234 example".&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 12:32:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518561#M74462</guid>
      <dc:creator>Aurora_TiffanyD</dc:creator>
      <dc:date>2022-07-07T12:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518564#M74463</link>
      <description>&lt;P&gt;This worked like a charm. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 12:52:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518564#M74463</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2022-07-07T12:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518565#M74464</link>
      <description>&lt;P&gt;One other option is to use Regex instead of Regex Match (there are also more options how this could be done, but I think Regex and Regex Match are the easiest ones)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

string = "Hello 0123 example";
four_num = Regex(string, "\d{4}");&amp;nbsp;//0123&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;See &lt;A href="https://regex101.com/r/26hBdb/1" target="_blank" rel="noopener"&gt;https://regex101.com/r/26hBdb/1&lt;/A&gt; for how regex this works if you are not familiar with it.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 12:52:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518565#M74464</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-07-07T12:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518566#M74465</link>
      <description>&lt;P&gt;This is probably better because you don't have to grab the first match.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 12:54:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518566#M74465</guid>
      <dc:creator>Aurora_TiffanyD</dc:creator>
      <dc:date>2022-07-07T12:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a string to extract numbers</title>
      <link>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518567#M74466</link>
      <description>&lt;P&gt;ok thank you&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/15446"&gt;@Aurora_TiffanyD&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 12:56:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Splitting-a-string-to-extract-numbers/m-p/518567#M74466</guid>
      <dc:creator>B1234</dc:creator>
      <dc:date>2022-07-07T12:56:28Z</dc:date>
    </item>
  </channel>
</rss>

