<?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: Select columns with a &amp;quot;pattern&amp;quot; in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617920#M81745</link>
    <description>&lt;P&gt;If you really need regex and have a recent version of JMP that includes FilterEach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );
colList = dt &amp;lt;&amp;lt; get column names( string );
// (&amp;gt;?.*?) is an atomic match for a reluctant (not greedy) match of 0 or more characters
// atomic is important when the match might fail to keep if from slowing down a lot on long names
Filter Each( {name}, colList, !Is Missing( Regex( name, "^((.e.)|((&amp;gt;?.*?)a(&amp;gt;?.*?)e.*))$" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;{"name", "age", "sex"}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Regex, as always, is more fun to write than read. Be careful with multiple .* in a single regex that might not match...it might try a lot of fruitless alternatives.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 18:28:23 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2023-03-29T18:28:23Z</dc:date>
    <item>
      <title>Select columns with a "pattern"</title>
      <link>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617874#M81739</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;This is a simple task but I didn't find an immediate way to do it.&lt;/P&gt;&lt;P&gt;I have a table with many columns (~5000); I need to select a subset of columns and then to extract a subset table.&lt;/P&gt;&lt;P&gt;The dumbest way to do it would be to pick each column from the column selector.&lt;/P&gt;&lt;P&gt;Actually, I could easily identify the column I need by applying to the column name a "pattern"&lt;/P&gt;&lt;P&gt;For example, let the column be the following:&lt;/P&gt;&lt;P&gt;AAA11&amp;nbsp;&lt;/P&gt;&lt;P&gt;AAA12&lt;BR /&gt;ABB22&lt;/P&gt;&lt;P&gt;XXX99&lt;/P&gt;&lt;P&gt;CAB32&lt;/P&gt;&lt;P&gt;CAB99&lt;/P&gt;&lt;P&gt;I need to select the columns whose name includes a "B" and terminates with a "2"&lt;/P&gt;&lt;P&gt;They could be identified by a pattern such as "*B*2" , where "*" is a wildcard.&lt;/P&gt;&lt;P&gt;In the example, the pattern would select "ABB22" and "CAB32"&lt;/P&gt;&lt;P&gt;I did not find&amp;nbsp; an easy way to do this.&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Emanuele&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Jun 2023 23:59:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617874#M81739</guid>
      <dc:creator>EV1976</dc:creator>
      <dc:date>2023-06-10T23:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Select columns with a "pattern"</title>
      <link>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617889#M81741</link>
      <description>&lt;P&gt;Here is a simple script to come up with a list of columns that meets the criteria&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
colList = dt &amp;lt;&amp;lt; get column names( string );
For( i = N Items( colList ), i &amp;gt;= 1, i--,
	If( !(Contains( colList[i], "B" ) &amp;amp; Right( colList[i], 1 ) == "2"),
		Remove From( colList, i, 1 )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Mar 2023 16:10:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617889#M81741</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-03-29T16:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select columns with a "pattern"</title>
      <link>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617920#M81745</link>
      <description>&lt;P&gt;If you really need regex and have a recent version of JMP that includes FilterEach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$sample_data/big class.jmp" );
colList = dt &amp;lt;&amp;lt; get column names( string );
// (&amp;gt;?.*?) is an atomic match for a reluctant (not greedy) match of 0 or more characters
// atomic is important when the match might fail to keep if from slowing down a lot on long names
Filter Each( {name}, colList, !Is Missing( Regex( name, "^((.e.)|((&amp;gt;?.*?)a(&amp;gt;?.*?)e.*))$" ) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;{"name", "age", "sex"}&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Regex, as always, is more fun to write than read. Be careful with multiple .* in a single regex that might not match...it might try a lot of fruitless alternatives.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 18:28:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-columns-with-a-quot-pattern-quot/m-p/617920#M81745</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-03-29T18:28:23Z</dc:date>
    </item>
  </channel>
</rss>

