<?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: how to extract string between specific pattern using regexp? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73132#M35712</link>
    <description>&lt;P&gt;Use this form instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name = Regex( string, "123450_([a-zA-Z ]+);", "\1" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 16 Sep 2018 15:53:49 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2018-09-16T15:53:49Z</dc:date>
    <item>
      <title>how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72823#M35682</link>
      <description>&lt;BR /&gt;Hi,&lt;BR /&gt;I am new to regex, i need to extract the name of users from their id, for example:&lt;BR /&gt;I have the following long string&lt;BR /&gt;123450_dan; 154396_kelli; 198756_dev;&lt;BR /&gt;Result need to be: dan&lt;BR /&gt;What regex do i need to use in order to extract the name dan which have the id 123450?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Sep 2018 09:17:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72823#M35682</guid>
      <dc:creator>Shlomizr</dc:creator>
      <dc:date>2018-09-14T09:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72850#M35688</link>
      <description>&lt;P&gt;You did not specifiy much detail about the ID so here are a few examples to get started. I used a JMP script, but this extraction could be used in a column formula, too.&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 );

// test string
string = "123450_dan; 154396_kelli; 198756_dev;";

// assume specific ID
name = Regex( string, "123450_(\w+\b)", "\1" );
Show( name );

// assume first ID with 6 numbers
name = Regex( string, "\d{6}_(\w+\b)", "\1" );
Show( name );

// assume first ID with any number of numbers
name = Regex( string, "\d+_(\w+\b)", "\1" );
Show( name );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 13:22:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72850#M35688</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-09-14T13:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72851#M35689</link>
      <description>&lt;P&gt;Assuming that you want fhe name associated with a specific ID in the parttern "id_name;", then this version will work, too.&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 );

// test string
string = "123450_dan; 154396_kelli; 198756_dev;";

// target ID
id = "123450";

// assume specific ID
name = Regex( string, id || "_(\w+);", "\1" );
Show( name );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 13:27:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72851#M35689</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-09-14T13:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72854#M35691</link>
      <description>Thanks Mark,&lt;BR /&gt;Working perfect!!</description>
      <pubDate>Fri, 14 Sep 2018 13:56:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72854#M35691</guid>
      <dc:creator>Shlomizr</dc:creator>
      <dc:date>2018-09-14T13:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72876#M35696</link>
      <description>&lt;P&gt;Just for fun, and because regular expressions can be tough to read by others (or two weeks later), Here is an alternative, using JMP functions.&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 );

// test string
string = "123450_dan; 154396_kelli; 198756_dev;";

//create a list of id_name
id = Words(string, ";");

//create a list if ids, a list if names, an associative array(keyed list) 
idlist={};
namelist={};
lookup = [=&amp;gt;""];  //Associative Array that retuns an empty string, if number is not valid

for(i=1, i&amp;lt;=nitems(id), i++,
   InsertInto(idlist, num(word(1,Trim(id[i]),"_")) );
   InsertInto(namelist, Titlecase(word(2,Trim(id[i]),"_")) ); //don't need TitleCase
   lookup[idlist[i]]=namelist[i]  //ids are the keys and names are the values
);
show(id, idlist, namelist, lookup, lookup[198756], lookup[128954]); //last one is not valid&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 18:13:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/72876#M35696</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-09-14T18:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73095#M35707</link>
      <description>Hi Mark,&lt;BR /&gt;Just 1 question, what do i need to add if i have space in the user name:&lt;BR /&gt;&lt;BR /&gt;for example: "123450_dan fox; 154396_kelli; 198756_dev;"&lt;BR /&gt;I tried the following Regex:&lt;BR /&gt;&lt;BR /&gt;string="123450_dan fox; 154396_kelli; 198756_dev;"&lt;BR /&gt;&lt;BR /&gt;name = Regex( string, "123450_(\w+ | \s+)", "\1" );&lt;BR /&gt;Show( name );&lt;BR /&gt;&lt;BR /&gt;Result: "dan" instead of "dan fox"&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;</description>
      <pubDate>Sun, 16 Sep 2018 06:55:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73095#M35707</guid>
      <dc:creator>Shlomizr</dc:creator>
      <dc:date>2018-09-16T06:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73096#M35708</link>
      <description>&lt;P&gt;The script that I provided previously using JMP functions would not require any modifications.&amp;nbsp; The regular expression to capture one or more "names" after the underscore would be &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;(\w+\s*)+&lt;/STRONG&gt;&lt;/FONT&gt; which means accumulate&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt; ( )&lt;/FONT&gt; &lt;/STRONG&gt;at&amp;nbsp; least one word &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;\w+&lt;/STRONG&gt;&lt;/FONT&gt;, zero or more spaces &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;\s*&lt;/STRONG&gt;&lt;/FONT&gt; and the trailing plus implies repeat the pattern one or more times.&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);
string="123450_dan fox; 154396_kelli ann marie; 198756_dev;";

name1 = Regex( string, "123450_((\w+\s*)+\b)", "\1" );
name2 = Regex( string, "154396_((\w+\s*)+\b)", "\1" );

Show( name1, name2 ); &lt;BR /&gt;/*: name1 = "dan fox";  name2 = "kelli ann marie"; */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Sep 2018 09:17:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73096#M35708</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-09-16T09:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73132#M35712</link>
      <description>&lt;P&gt;Use this form instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;name = Regex( string, "123450_([a-zA-Z ]+);", "\1" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Sep 2018 15:53:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73132#M35712</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-09-16T15:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73231#M35717</link>
      <description>Thanks, work perfect.&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Sep 2018 06:32:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73231#M35717</guid>
      <dc:creator>Shlomizr</dc:creator>
      <dc:date>2018-09-17T06:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract string between specific pattern using regexp?</title>
      <link>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73232#M35718</link>
      <description>&lt;P&gt;Thanks, work perfect!!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 06:34:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/how-to-extract-string-between-specific-pattern-using-regexp/m-p/73232#M35718</guid>
      <dc:creator>Shlomizr</dc:creator>
      <dc:date>2018-09-17T06:34:43Z</dc:date>
    </item>
  </channel>
</rss>

