cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
dadawasozo
Level IV

split long string based on position of delimiter

Hi

I have a column that has long strings (see example below). I want to extract all the text after the 7th delimiter of "_"  from the right. I tried munger but doesnt seem working well at the end part.

 

can someone provide suggestion how I can do it right?

 

1)shjdjsh._ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a

desired output: ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a
2)hhd_wew_klf:_jdbfjdf_qwkokv_ctls_msdn_a_f_g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf
desired output: g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: split long string based on position of delimiter

You could use Word() with negative indices

Names Default To Here(1);

str1 = "shjdjsh._ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a";
result1 = "ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a";

str2 = "hhd_wew_klf:_jdbfjdf_qwkokv_ctls_msdn_a_f_g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf";
result2 = "g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf";

res1 = Word([-8 -1], str1, "_");
res2 = Word([-8 -1], str2, "_");

res1 == result1;
res2 == result2;
-Jarmo

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: split long string based on position of delimiter

Here is the formula I used

Substr(
	:Column 1,
	Contains( :Column 1, Word( -8, :Column 1, "_" ) )
)

txnelson_0-1719069880382.png

 

Jim
jthi
Super User

Re: split long string based on position of delimiter

You could use Word() with negative indices

Names Default To Here(1);

str1 = "shjdjsh._ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a";
result1 = "ndjrpe_hfkjd_tyrwytre5_hlhm_jgds.d._jkdjf_hfkd_a";

str2 = "hhd_wew_klf:_jdbfjdf_qwkokv_ctls_msdn_a_f_g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf";
result2 = "g_skjd_lad_vtl_sdjnskjshdja_jndf_skdj_ccf";

res1 = Word([-8 -1], str1, "_");
res2 = Word([-8 -1], str2, "_");

res1 == result1;
res2 == result2;
-Jarmo