Hi,
It is always challenging to parse strings when you do not have clear delimiters.
Assuming that the input string will always contain the keywords "Customer:", "Product:", and "Region:", you can use the approach below:
- Replace the keywords with "," using the SUBSTITUTE() function
- Parse the relevant information using the WORD() function
- Clean up the resulting strings with the TRIM() function.
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 )
)
)
I hope it helps.
Best,
TS
Thierry R. Sornasse