Extracting text from a column of stringsHello,
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:
D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_DX7DY11SDX11SDY15_2024-12-06_18-57-42.jpg
I would want to extract and create these columns:

Of course, I would like to repeat this process over an entire column of data. I'd appreciate any advice. Thanks!
Automation and ScriptingRe: Extracting text from a column of stringsDo you know beforehand all the possible patterns (DX, DY, ....)? Is it always located in the same place (after }_ and before date)?
Re: Extracting text from a column of stringsIf I had a column full of those filenames, I would do a Cols -> Recode, top-left Red Triangle -> "Replace String", and then enter "S?D[XY](\d+)" and replace with "%\1%" with "Use regular expressions" turned on. Then you can split the column (Cols -> Utilities -> Text to Columns...") and enter "%", which will give you 6 new columns, with the prefix, DX, DY, SDX, SDY, and suffix, e.g.:
| Column 1 2 | Column 1 3 | Column 1 4 | Column 1 5 | Column 1 6 | Column 1 7 |
| D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_ | 7 | 11 | 11 | 15 | _2024-12-06_18-57-42.jpg |
Then you can rename the columns to DX, DY, etc.
If your real data is more complicated this process might need to be a bit more complicated as well.
Re: Extracting text from a column of stringsNice : )
maybe start with
word(8, filename,"_")
such that it works as well for lot DX11A.
Re: Extracting text from a column of stringsIt helped me, Thank you so much for the help.
View more...To extract text from a column of strings in JMP, you can use formulas or scripts. Common methods include regular expressions for pattern matching or substring functions to isolate specific text. The **Regex()** function is versatile for complex patterns, while simpler extractions can utilize **Left(), Right(),** or **Substring()** functions effectively. During a particularly challenging semester, I came across
https://canadianwritings.com/ and it turned out to be a lifesaver. I needed help with an essay on modern literature, and the service provided a well-researched and perfectly structured paper. The writer followed my instructions to the letter, and the final result was impressive. Plus, they delivered the essay ahead of the deadline, which gave me time to review it properly before submitting it.
Re: Extracting text from a column of stringsHere is an alternative approach.
Given the data table

The below script will directly create

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 << New Column( "DX" );
dt << New Column( "DY" );
dt << New Column( "SDX" );
dt << 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 ) );
);