<?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: Extracting text from a column of strings in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/825737#M100616</link>
    <description>&lt;P&gt;Here is an alternative approach.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the data table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1735902155727.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71655iE76DC79D83E000F9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1735902155727.png" alt="txnelson_0-1735902155727.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The below script will directly create&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1735902223229.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71656i10BAFF877D5ADBC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1735902223229.png" alt="txnelson_1-1735902223229.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create and example data table
dt = New Table( "Example",
	Add Rows( 1 ),
	New Column( "File",
		Character,
		"Nominal",
		Set Values(
			{
			"D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_DX7DY11SDX11SDY15_2024-12-06_18-57-42.jpg"
			}
		)
	)
);

// Add the new columns to the data table
dt &amp;lt;&amp;lt; New Column( "DX" );
dt &amp;lt;&amp;lt; New Column( "DY" );
dt &amp;lt;&amp;lt; New Column( "SDX" );
dt &amp;lt;&amp;lt; New Column( "SDY" );

For Each Row(
	// Separate the section of the File name into just the DX,DY,SDX,SDY part
	string = Word( 1, Substr( :file, Contains( :file, "_DX" ) + 1 ), "_" );
	// Change the string into a assignment statements
	Substitute Into( string, "SDX", ";:SD_X=", "SDY", ";:SD_Y=", "DX", ";:D_X=", "DY", ";:D_Y=", "_", "" );
	string = Substr( string, 2 ) || ";";
	// Execute the assignment statements
	Eval( Parse( string ) );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Jan 2025 11:04:17 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2025-01-03T11:04:17Z</dc:date>
    <item>
      <title>Extracting text from a column of strings</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823791#M100299</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am a bit of a novice when it comes to scripting in JMP, and I am trying to write a script that would be able to extract specific numbers from a string and create new columns for each one. Each number would always follow the characters 'DX' or 'DY' For example:&lt;BR /&gt;&lt;BR /&gt;D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_DX7DY11SDX11SDY15_2024-12-06_18-57-42.jpg&lt;BR /&gt;&lt;BR /&gt;I would want to extract and create these columns:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SethTruex_0-1734372111786.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71275iA00CD4D9BB1F9D0D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SethTruex_0-1734372111786.png" alt="SethTruex_0-1734372111786.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Of course, I would like to repeat this process over an entire column of data. I'd appreciate any advice. Thanks!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 18:05:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823791#M100299</guid>
      <dc:creator>Seth</dc:creator>
      <dc:date>2024-12-16T18:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from a column of strings</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823801#M100300</link>
      <description>&lt;P&gt;Do you know beforehand all the possible patterns (DX, DY, ....)? Is it always located in the same place (after }_ and before date)?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 18:32:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823801#M100300</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-12-16T18:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from a column of strings</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823803#M100302</link>
      <description>&lt;P&gt;If I had a column full of those filenames, I would do a Cols -&amp;gt; Recode, top-left Red Triangle -&amp;gt; "Replace String", and then enter "S?D[XY](\d+)" and replace with "%\1%" with "Use regular expressions" turned on.&amp;nbsp; Then you can split the column (Cols -&amp;gt; Utilities -&amp;gt; Text to Columns...") and enter "%", which will give you 6 new columns, with the prefix, DX, DY, SDX, SDY, and suffix, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Column 1 2&lt;/TD&gt;&lt;TD&gt;Column 1 3&lt;/TD&gt;&lt;TD&gt;Column 1 4&lt;/TD&gt;&lt;TD&gt;Column 1 5&lt;/TD&gt;&lt;TD&gt;Column 1 6&lt;/TD&gt;&lt;TD&gt;Column 1 7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;_2024-12-06_18-57-42.jpg&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can rename the columns to DX, DY, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your real data is more complicated this process might need to be a bit more complicated as well.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 19:32:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823803#M100302</guid>
      <dc:creator>BHarris</dc:creator>
      <dc:date>2024-12-16T19:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from a column of strings</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823825#M100310</link>
      <description>&lt;P&gt;Nice : )&lt;BR /&gt;maybe start with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;word(8, filename,"_")&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;such that it works as well for lot &lt;FONT face="courier new,courier"&gt;DX11A&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 20:53:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/823825#M100310</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-12-16T20:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting text from a column of strings</title>
      <link>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/825737#M100616</link>
      <description>&lt;P&gt;Here is an alternative approach.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given the data table&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1735902155727.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71655iE76DC79D83E000F9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1735902155727.png" alt="txnelson_0-1735902155727.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The below script will directly create&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1735902223229.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/71656i10BAFF877D5ADBC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1735902223229.png" alt="txnelson_1-1735902223229.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create and example data table
dt = New Table( "Example",
	Add Rows( 1 ),
	New Column( "File",
		Character,
		"Nominal",
		Set Values(
			{
			"D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_DX7DY11SDX11SDY15_2024-12-06_18-57-42.jpg"
			}
		)
	)
);

// Add the new columns to the data table
dt &amp;lt;&amp;lt; New Column( "DX" );
dt &amp;lt;&amp;lt; New Column( "DY" );
dt &amp;lt;&amp;lt; New Column( "SDX" );
dt &amp;lt;&amp;lt; New Column( "SDY" );

For Each Row(
	// Separate the section of the File name into just the DX,DY,SDX,SDY part
	string = Word( 1, Substr( :file, Contains( :file, "_DX" ) + 1 ), "_" );
	// Change the string into a assignment statements
	Substitute Into( string, "SDX", ";:SD_X=", "SDY", ";:SD_Y=", "DX", ";:D_X=", "DY", ";:D_Y=", "_", "" );
	string = Substr( string, 2 ) || ";";
	// Execute the assignment statements
	Eval( Parse( string ) );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Jan 2025 11:04:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extracting-text-from-a-column-of-strings/m-p/825737#M100616</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-01-03T11:04:17Z</dc:date>
    </item>
  </channel>
</rss>

