cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Seth
Level I

Extracting text from a column of strings

Hello,

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:

SethTruex_0-1734372111786.png

Of course, I would like to repeat this process over an entire column of data. I'd appreciate any advice. Thanks!



3 REPLIES 3
jthi
Super User

Re: Extracting text from a column of strings

Do you know beforehand all the possible patterns (DX, DY, ....)? Is it always located in the same place (after }_ and before date)?

-Jarmo
BHarris
Level VI

Re: Extracting text from a column of strings

If 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 2Column 1 3Column 1 4Column 1 5Column 1 6Column 1 7
D113U_NTCH_CM_MEAS_CD_SEM_{2UM_X6_NTCH_CM_IMAGE}_7111115 _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.

hogi
Level XII

Re: Extracting text from a column of strings

Nice : )
maybe start with 

 

word(8, filename,"_")

such that it works as well for lot DX11A.