<?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: Extract failure part code from unstructured string in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699795#M88458</link>
    <description>&lt;P&gt;Capturing multiple things with single regex isn't that simple in JMP as there isn't global matching possibility (&lt;/P&gt;
&lt;DIV class="lia-byline-wrapper"&gt;&lt;LI-MESSAGE title="Add flag to Regex Match() to find all non-overlapping occurances of pattern" uid="582080" url="https://community.jmp.com/t5/JMP-Wish-List/Add-flag-to-Regex-Match-to-find-all-non-overlapping-occurances/m-p/582080#U582080" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;). To capture all cases, you will have to use JMPs pattern matching which can be very complicated to use.&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This fairly simple regex does capture first codes for you&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/data1.jmp");

failure_pattern = "[A-Z]+\d+[A-Z]?";

Eval(EvalExpr(
	dt &amp;lt;&amp;lt; New Column("A", Character, Nominal, &amp;lt;&amp;lt; Formula(
		Regex(:Repair Details, Expr(failure_pattern));
	));
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then pattern matching mess (can be most likely made much better)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/data1.jmp");

str = "failure parts replaced (K3; LG69; AK4T). Proceed to next test";

dt &amp;lt;&amp;lt; New Column("A", Character, Nominal, &amp;lt;&amp;lt; Formula(
	failure_pattern = "([A-Z]+\d+[A-Z]?){1,}";
	found_list = {};
	Pat Match(:Repair Details,
		Pat Any(", (") + Pat Regex(failure_pattern) &amp;gt;&amp;gt; match + Pat Any(" .;,)") + Pat Test(
			Insert Into(found_list, match);
			0
		)
	);
	Concat Items(found_list, ", ");
)); &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Nov 2023 10:24:00 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-11-17T10:24:00Z</dc:date>
    <item>
      <title>Extract failure part code from unstructured string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699685#M88450</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to extract failure part codes from the&amp;nbsp;unstructured string below using Regex in JSL. But I was not success to get it because it is complicated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Repair T126 &amp;amp; PA21. retest pass&lt;BR /&gt;change L6C, FTNG4 reroute for retest&lt;BR /&gt;Test 1 failure part P12; M531, Z6A2. Test 2 failure part Z100, RT98; BTGH9. Rework all the parts&lt;BR /&gt;failure parts replaced (K3; LG69; AK4T). Proceed to next test&lt;BR /&gt;damaged part YT10 rework the part, proceed to next process&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Required outcome in column "Failure Part Code" should look something this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bzanos_1-1700203089664.png" style="width: 708px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/58858i1279497E31BC1C22/image-dimensions/708x122?v=v2" width="708" height="122" role="button" title="bzanos_1-1700203089664.png" alt="bzanos_1-1700203089664.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice and help would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 07:00:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699685#M88450</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2023-11-17T07:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extract failure part code from unstructured string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699795#M88458</link>
      <description>&lt;P&gt;Capturing multiple things with single regex isn't that simple in JMP as there isn't global matching possibility (&lt;/P&gt;
&lt;DIV class="lia-byline-wrapper"&gt;&lt;LI-MESSAGE title="Add flag to Regex Match() to find all non-overlapping occurances of pattern" uid="582080" url="https://community.jmp.com/t5/JMP-Wish-List/Add-flag-to-Regex-Match-to-find-all-non-overlapping-occurances/m-p/582080#U582080" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;). To capture all cases, you will have to use JMPs pattern matching which can be very complicated to use.&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This fairly simple regex does capture first codes for you&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/data1.jmp");

failure_pattern = "[A-Z]+\d+[A-Z]?";

Eval(EvalExpr(
	dt &amp;lt;&amp;lt; New Column("A", Character, Nominal, &amp;lt;&amp;lt; Formula(
		Regex(:Repair Details, Expr(failure_pattern));
	));
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then pattern matching mess (can be most likely made much better)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$DOWNLOADS/data1.jmp");

str = "failure parts replaced (K3; LG69; AK4T). Proceed to next test";

dt &amp;lt;&amp;lt; New Column("A", Character, Nominal, &amp;lt;&amp;lt; Formula(
	failure_pattern = "([A-Z]+\d+[A-Z]?){1,}";
	found_list = {};
	Pat Match(:Repair Details,
		Pat Any(", (") + Pat Regex(failure_pattern) &amp;gt;&amp;gt; match + Pat Any(" .;,)") + Pat Test(
			Insert Into(found_list, match);
			0
		)
	);
	Concat Items(found_list, ", ");
)); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Nov 2023 10:24:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699795#M88458</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-11-17T10:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract failure part code from unstructured string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699894#M88474</link>
      <description>&lt;P&gt;I recently discovered a JMP function/option that can handle this pretty easily.&amp;nbsp; New Column by Text Matching.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try this script or use the utility under Cols-&amp;gt;Utilities with your Repair Details column selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Column by Text Matching(
	Column( :Repair Details ),
	Set Regex( Custom( Title( "parts" ), Regex( "([A-Z]+\d+[A-Z]?)" ), Result( "\[\1]\" ), ) ),
	Output Column Name( "Failure Part Code" )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmarchandTSI_0-1700228913630.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/58870iE27FECBCFD0AB7C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmarchandTSI_0-1700228913630.png" alt="mmarchandTSI_0-1700228913630.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 13:51:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/699894#M88474</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2023-11-17T13:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract failure part code from unstructured string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/700332#M88505</link>
      <description>&lt;P&gt;Thanks Jarmo. This is great!&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 14:04:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/700332#M88505</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2023-11-18T14:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extract failure part code from unstructured string</title>
      <link>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/700333#M88506</link>
      <description>&lt;P&gt;Thanks for sharing this function "&lt;SPAN&gt;New Column by Text Matching&lt;/SPAN&gt;". It helps.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Nov 2023 14:07:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Extract-failure-part-code-from-unstructured-string/m-p/700333#M88506</guid>
      <dc:creator>bzanos</dc:creator>
      <dc:date>2023-11-18T14:07:49Z</dc:date>
    </item>
  </channel>
</rss>

