<?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 help in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Regex-help/m-p/48760#M27717</link>
    <description>&lt;P&gt;Right now you are matching &lt;EM&gt;either&lt;/EM&gt; an 'a' at the beginning of the string ('^a') &lt;EM&gt;or&lt;/EM&gt; an 'A' followed by zero or more letters 'L' or 'B' ('A[LB]*').&amp;nbsp; Some notes:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;There are no parenthesis around the or so the match is either the entire string before or after the '|'.&amp;nbsp; So if the string starts with 'a' it is done and will not match anything else.&lt;/LI&gt;&lt;LI&gt;The square brackets mean match any character inside them.&lt;/LI&gt;&lt;LI&gt;The asterisk means match zero or more of the preceeding character or group, in this case that means the group inside the squre brackets.&lt;/LI&gt;&lt;LI&gt;Together, right side of the or will match any of these, anywhere&amp;nbsp;inside your string (not just at the beginning):&lt;/LI&gt;&lt;OL&gt;&lt;LI&gt;A&lt;/LI&gt;&lt;LI&gt;AL&lt;/LI&gt;&lt;LI&gt;AB&lt;/LI&gt;&lt;LI&gt;ALB&lt;/LI&gt;&lt;LI&gt;ABL&lt;/LI&gt;&lt;LI&gt;ALLLLLLLLLLBLLBBBBLLBLLB&lt;/LI&gt;&lt;/OL&gt;&lt;LI&gt;The string aA would actually be two different matches of the Regex function.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;You probably want this: "^(a|A)LB.*$", or this: "^[aA]LB.*$"&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Starting at the beginning of the string, match an a or A, followed by&lt;/LI&gt;&lt;LI&gt;The characters LB, in order, followed by&lt;/LI&gt;&lt;LI&gt;Zero or more of any character, the period is any character&amp;nbsp;(.*), followed by&lt;/LI&gt;&lt;LI&gt;The end of the string.&amp;nbsp; This is probably not necessary.&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Des = {"ALBANY", "aLBUQUERQUE"};&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check out &lt;A href="https://regexr.com/" target="_self"&gt;regexr.com&lt;/A&gt;, it not only helps check your code but has good 'reference' and 'cheatsheet' sections on the left.&amp;nbsp; I almost always&amp;nbsp;turn multiline on (flags in the upper right).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited to clarify that&amp;nbsp;match can be anywhere inside the string.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Dec 2017 15:40:09 GMT</pubDate>
    <dc:creator>ih</dc:creator>
    <dc:date>2017-12-16T15:40:09Z</dc:date>
    <item>
      <title>Regex help</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-help/m-p/48759#M27716</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Trying to explore Regular Expressions a little better . I can achieve what I want with a simple Contains() - but trying to see what the equivalent would be using Regular Expressions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The regex I have doesn't work the way I expect it to , can somebody point me to the equivalent regex and explain what I have gotten wrong ?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Log(); Clear Globals(); 
dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt:city[2] = "aLBUQUERQUE"; 
CityList = dt:City &amp;lt;&amp;lt; Get Values; 
Des = list(); 

for(i = 1 , i &amp;lt;= N Items(CityList),i++,
		If(!IsMissing(Regex(Char(CityList[i]),"^a|A[LB]*")),
			Insert Into(Des,CityList[i]);
	 	  );
   );

/*for(i = 1 , i &amp;lt;= N Items(CityList) , i++,
		If(Contains(CityList[i],"aLB")|Contains(CityList[i],"ALB"),
			Insert Into(Des,CityList[i]);
		  );
   );*/
   
Show(Des);
//Close All(Data Tables,"No Save");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Dec 2017 04:19:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-help/m-p/48759#M27716</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2017-12-16T04:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Regex help</title>
      <link>https://community.jmp.com/t5/Discussions/Regex-help/m-p/48760#M27717</link>
      <description>&lt;P&gt;Right now you are matching &lt;EM&gt;either&lt;/EM&gt; an 'a' at the beginning of the string ('^a') &lt;EM&gt;or&lt;/EM&gt; an 'A' followed by zero or more letters 'L' or 'B' ('A[LB]*').&amp;nbsp; Some notes:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;There are no parenthesis around the or so the match is either the entire string before or after the '|'.&amp;nbsp; So if the string starts with 'a' it is done and will not match anything else.&lt;/LI&gt;&lt;LI&gt;The square brackets mean match any character inside them.&lt;/LI&gt;&lt;LI&gt;The asterisk means match zero or more of the preceeding character or group, in this case that means the group inside the squre brackets.&lt;/LI&gt;&lt;LI&gt;Together, right side of the or will match any of these, anywhere&amp;nbsp;inside your string (not just at the beginning):&lt;/LI&gt;&lt;OL&gt;&lt;LI&gt;A&lt;/LI&gt;&lt;LI&gt;AL&lt;/LI&gt;&lt;LI&gt;AB&lt;/LI&gt;&lt;LI&gt;ALB&lt;/LI&gt;&lt;LI&gt;ABL&lt;/LI&gt;&lt;LI&gt;ALLLLLLLLLLBLLBBBBLLBLLB&lt;/LI&gt;&lt;/OL&gt;&lt;LI&gt;The string aA would actually be two different matches of the Regex function.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;You probably want this: "^(a|A)LB.*$", or this: "^[aA]LB.*$"&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Starting at the beginning of the string, match an a or A, followed by&lt;/LI&gt;&lt;LI&gt;The characters LB, in order, followed by&lt;/LI&gt;&lt;LI&gt;Zero or more of any character, the period is any character&amp;nbsp;(.*), followed by&lt;/LI&gt;&lt;LI&gt;The end of the string.&amp;nbsp; This is probably not necessary.&lt;/LI&gt;&lt;/OL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Des = {"ALBANY", "aLBUQUERQUE"};&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Check out &lt;A href="https://regexr.com/" target="_self"&gt;regexr.com&lt;/A&gt;, it not only helps check your code but has good 'reference' and 'cheatsheet' sections on the left.&amp;nbsp; I almost always&amp;nbsp;turn multiline on (flags in the upper right).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited to clarify that&amp;nbsp;match can be anywhere inside the string.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Dec 2017 15:40:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Regex-help/m-p/48760#M27717</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2017-12-16T15:40:09Z</dc:date>
    </item>
  </channel>
</rss>

