<?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 select patterns based on segments of strings in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/35745#M21100</link>
    <description>&lt;P&gt;Hafiz,&lt;/P&gt;
&lt;P&gt;I am happy that I have been able to help you solve your problem.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 11:17:49 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-02-14T11:17:49Z</dc:date>
    <item>
      <title>How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34839#M20582</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm a new user of JSL. In order to group a large number of &amp;nbsp;pins and adding a new columns for those groups, I'm thinking to use JSL. I got to know how to do that for first consecutive characters (e.g. for DDR0CH0CKN... I know how to filter it using DDR0...) but if I'm to do that using&amp;nbsp;segments like 'DDR0' and 'CK',&amp;nbsp;what would be an efficient way to do&amp;nbsp;that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI:&amp;nbsp;One way, I know,&amp;nbsp;is to use a manually created file and then use update command to match pins to pin groups (not an efficient way). I tried patMatch/regex etc. but could not get the desired result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your convenience, I've attached .jmp file where I want to have a column called "Desired_Pin_Group" for the pins.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your cooperation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hafiz.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 03:38:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34839#M20582</guid>
      <dc:creator>mhafiz</dc:creator>
      <dc:date>2017-01-23T03:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34842#M20585</link>
      <description>&lt;P&gt;Here is a script that will do what you want, given the example you gave.&amp;nbsp; If you have a lot more pin combinations that require exception processing this may not be the best way to handle this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
dt &amp;lt;&amp;lt; New Column( "Generated Pin Group", character );

For Each Row(
// Get the first part of the group name
	First = Lowercase( Substr( :Pin, 1, 4 ) );

// Handle exceptions like the below case
	If( First == "ddrr",
		First = "ddr0"
	);

// Now attach the "_"
	First = First || "_";

// Now add the second part based upon the given complexities

	// Handle the clk
	If(
		Contains( :Pin, "_CK" ) &amp;gt; 0 &amp;amp; Contains( :Pin, "_CKE" ) == 0, First = First || "clk", 
	// Handle the vref
		Contains( :Pin, "_VREF" ) &amp;gt; 0, First = First || "vref", 
	// Handle the cke
		Contains( :Pin, "_CKE" ) &amp;gt; 0, First = First || "cke", 
	// Handle the reset
		Contains( :Pin, "RESET" ) &amp;gt; 0, First = First || "Reset"
	);
	:Generated Pin Group = First;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to do this as a formula for a column, it is just a simple change&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;First = Lowercase( Substr( :Pin, 1, 4 ) );
If( First == "ddrr",
	First = "ddr0"
);
First = First || "_";
If(
	Contains( :Pin, "_CK" ) &amp;gt; 0 &amp;amp; Contains( :Pin, "_CKE" ) == 0,
		First = First || "clk",
	Contains( :Pin, "_VREF" ) &amp;gt; 0, First = First || "vref",
	Contains( :Pin, "_CKE" ) &amp;gt; 0, First = First || "cke",
	Contains( :Pin, "RESET" ) &amp;gt; 0, First = First || "Reset"
);
First;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jan 2017 05:59:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34842#M20585</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-01-23T05:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34859#M20596</link>
      <description>&lt;P&gt;Thanks for your quick response. The script is quite ok for the .jmp file that I gave previously. But, unfortunately it's not that straightforward. The number of pins is in the range of 150-200 and those are grouped within 15-20 groups. Please have a look at the newly attached .jmp file, it's closer to the real scenario. Just have a look from 22-27 and 81-83. Those 2 groups have DDR_Y in common, but they are filtered based on other phrases within the string. The logic is&amp;nbsp;something like: if :Pin=='DDR_Y' &amp;amp;&amp;amp; Pin != NC :Desired_Pin_Group=ddr_dq_ch0 else :Desired_Pin_Group=ddr_ctrl. The distinguishing criteria between the groups (81-83) and (93-96) are even more complex. One needs to search the last phrases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your cooperation is highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hafiz.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 16:15:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34859#M20596</guid>
      <dc:creator>mhafiz</dc:creator>
      <dc:date>2017-01-23T16:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34873#M20603</link>
      <description>&lt;P&gt;JMP provides an entire &lt;EM&gt;pattern matching&lt;/EM&gt; suite&amp;nbsp;of functions and constructs that you might find useful here. See &lt;STRONG&gt;Help&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Books&lt;/STRONG&gt; &amp;gt; &lt;STRONG&gt;Scripting Guide&lt;/STRONG&gt;. Then search for this section in the book.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 18:34:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/34873#M20603</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-01-23T18:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/35740#M21097</link>
      <description>&lt;P&gt;Hi txnelson,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the concept of the conditional statement that you provided and could solve my issue. Rather than converting to lowercase, I added a new column in the table and put the pin name directly using parenthesis, as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dt &amp;lt;&amp;lt;New Column("Match_Pin_Grp", Character, Nominal,&lt;BR /&gt;Formula(&lt;BR /&gt;If(Contains(:Pin, "_CK")&amp;gt;0 &amp;amp; Contains(:Pin,"DDR0") &amp;amp; Contains(:Pin, "_CKE")==0,"ddr0_clk",&lt;BR /&gt;Contains(:Pin, "_CK")&amp;gt;0 &amp;amp; Contains(:Pin,"DDR1") &amp;amp; Contains(:Pin, "_CKE")==0,"ddr1_clk",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'm accepting it as a solution to the problem.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hafiz.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 06:50:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/35740#M21097</guid>
      <dc:creator>mhafiz</dc:creator>
      <dc:date>2017-02-14T06:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to select patterns based on segments of strings</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/35745#M21100</link>
      <description>&lt;P&gt;Hafiz,&lt;/P&gt;
&lt;P&gt;I am happy that I have been able to help you solve your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 11:17:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-select-patterns-based-on-segments-of-strings/m-p/35745#M21100</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-02-14T11:17:49Z</dc:date>
    </item>
  </channel>
</rss>

