<?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: String Parsing Question in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744978#M92477</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It is always challenging to parse strings when you do not have clear delimiters.&lt;/P&gt;
&lt;P&gt;Assuming that the input string will always contain the keywords "Customer:", "Product:", and "Region:", you can use the approach below:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Replace the keywords with "," using the SUBSTITUTE() function&lt;/LI&gt;
&lt;LI&gt;Parse the relevant information using the WORD() function&lt;/LI&gt;
&lt;LI&gt;Clean up the resulting strings with the TRIM() function.&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Sample_PARSED",
	Add Rows( 2 ),
	New Column( "Field_9630",
		Character,
		"Nominal",
		Set Values(
			{"Customer: Mr A LoyalProduct: Cabinet HardwareRegion: Suburban New Dev",
			"Customer: Jenifer B Ashley LeighProduct: LumberRegion: Suburban Existing"
			}
		),
		Set Display Width( 726 )
	),
	New Column( "TEMP",
		Character,
		"Nominal",
		Formula(
			Substitute( :Field_9630,
				"Customer:", ",",
				"Product:", ",",
				"Region:", ","
			)
		)
	),
	New Column( "Column 2",
		Character,
		"Nominal",
		Formula( Trim( Word( 1, :TEMP, "," ) ) ),
		Set Display Width( 157 )
	),
	New Column( "Column 3",
		Character,
		"Nominal",
		Formula( Trim( Word( 2, :TEMP, "," ) ) )
	),
	New Column( "Column 4",
		Character,
		"Nominal",
		Formula( Trim( Word( 3, :TEMP, "," ) ) ),
		Set Display Width( 200 )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Sat, 06 Apr 2024 19:21:58 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2024-04-06T19:21:58Z</dc:date>
    <item>
      <title>String Parsing Question</title>
      <link>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744967#M92476</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am receiving data with identifying information in 1 cell.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt = New Table("Sample",
add rows(2),
	New Column( "Field_9630", Character, "Nominal" )
);

dt:Field_9630 &amp;lt;&amp;lt; Set Values({"Customer: Mr A LoyalProduct: Cabinet HardwareRegion: Suburban New Dev", "Customer: Jenifer B Ashley LeighProduct: LumberRegion: Suburban Existing"});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The target is to produce three columns - Customer, Product, Region&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt2 = New Table( "Sample 2",
	Add Rows( 2 ),
	New Column( "Field_9630",
		Character,
		"Nominal",
		Set Selected,
		Set Values(
			{"Customer: Mr A LoyalProduct: Cabinet HardwareRegion: Suburban New Dev",
			"Customer: Jenifer B Ashley LeighProduct: LumberRegion: Suburban Existing"
			}
		),
		Set Display Width( 132 )
	),
	New Column( "Customer",
		Character,
		"Nominal",
		Set Values( {"Mr A Loyal", "Jenifer B Ashley Leigh"} )
	),
	New Column( "Product",
		Character,
		"Nominal",
		Set Values( {"Cabinet Hardware", "Lumber"} )
	),
	New Column( "Region",
		Character,
		"Nominal",
		Set Values( {"Suburban New Dev", "Suburban Existing"} )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;MG&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 18:54:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744967#M92476</guid>
      <dc:creator>modelFit</dc:creator>
      <dc:date>2024-04-06T18:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: String Parsing Question</title>
      <link>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744978#M92477</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It is always challenging to parse strings when you do not have clear delimiters.&lt;/P&gt;
&lt;P&gt;Assuming that the input string will always contain the keywords "Customer:", "Product:", and "Region:", you can use the approach below:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Replace the keywords with "," using the SUBSTITUTE() function&lt;/LI&gt;
&lt;LI&gt;Parse the relevant information using the WORD() function&lt;/LI&gt;
&lt;LI&gt;Clean up the resulting strings with the TRIM() function.&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Sample_PARSED",
	Add Rows( 2 ),
	New Column( "Field_9630",
		Character,
		"Nominal",
		Set Values(
			{"Customer: Mr A LoyalProduct: Cabinet HardwareRegion: Suburban New Dev",
			"Customer: Jenifer B Ashley LeighProduct: LumberRegion: Suburban Existing"
			}
		),
		Set Display Width( 726 )
	),
	New Column( "TEMP",
		Character,
		"Nominal",
		Formula(
			Substitute( :Field_9630,
				"Customer:", ",",
				"Product:", ",",
				"Region:", ","
			)
		)
	),
	New Column( "Column 2",
		Character,
		"Nominal",
		Formula( Trim( Word( 1, :TEMP, "," ) ) ),
		Set Display Width( 157 )
	),
	New Column( "Column 3",
		Character,
		"Nominal",
		Formula( Trim( Word( 2, :TEMP, "," ) ) )
	),
	New Column( "Column 4",
		Character,
		"Nominal",
		Formula( Trim( Word( 3, :TEMP, "," ) ) ),
		Set Display Width( 200 )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope it helps.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 19:21:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744978#M92477</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2024-04-06T19:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: String Parsing Question</title>
      <link>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744979#M92478</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;Thanks for the quick reply and solution. Much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 19:25:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/String-Parsing-Question/m-p/744979#M92478</guid>
      <dc:creator>modelFit</dc:creator>
      <dc:date>2024-04-06T19:25:07Z</dc:date>
    </item>
  </channel>
</rss>

