<?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 Confusion using word( ) function and specified delimiter in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78637#M36484</link>
    <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to manipulate my column names. It's very easy to do once or twice with Find/Replace but I'd like to script it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I want to change a column name from "Singlets/Live leukocytes/Lymphocytes/B cells/A+B+C-,Freq. of Parent" to "&lt;SPAN&gt;B cells/A+B+C-,Freq. of Parent".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table ();

colList = dt &amp;lt;&amp;lt; get column names(string);

For ( i = 1, i &amp;lt;= N Items(colList), i++, 
	If (
		contains(colList[i], "Singlets/Live leukocytes/Lymphocytes/"), &lt;BR /&gt;	
		Column(dt, colList[i]) &amp;lt;&amp;lt; set name (Word(2, colList[i], "Lymphocytes/"))		
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run parts of this code individually, here's what I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;line of code:&lt;/P&gt;&lt;P&gt;result in script log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colList[i]:
"Singlets/Live leukocytes/Lymphocytes/B cells/A+B+C-,Freq. of Parent"


contains(colList[i], "Singlets/Live leukocytes/Lymphocytes/"):
1

Word(2, colList[i], "Lymphocytes/"):
"iv"

Word(3, colList[i], "Lymphocytes/"):
" l"

Word(4, colList[i], "Lymphocytes/"):
"uk"

Word(9, colList[i], "Lymphocytes/"):
"f Par"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clearly, my delimiter isn't working the way I expect it to. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I originally tried to do Words(4, colList[i], "/") but that only gave me "B cells" since there is another / immediately after that. Unlike other programming languages, I don't know if there is a way to specify '4th word and then everything afterwards until the end' in JSL. I don't think this is possible so I changed the delimiter, thinking that would solve my problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for any advice!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 18:26:34 GMT</pubDate>
    <dc:creator>lakepotter</dc:creator>
    <dc:date>2018-10-10T18:26:34Z</dc:date>
    <item>
      <title>Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78637#M36484</link>
      <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to manipulate my column names. It's very easy to do once or twice with Find/Replace but I'd like to script it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, I want to change a column name from "Singlets/Live leukocytes/Lymphocytes/B cells/A+B+C-,Freq. of Parent" to "&lt;SPAN&gt;B cells/A+B+C-,Freq. of Parent".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table ();

colList = dt &amp;lt;&amp;lt; get column names(string);

For ( i = 1, i &amp;lt;= N Items(colList), i++, 
	If (
		contains(colList[i], "Singlets/Live leukocytes/Lymphocytes/"), &lt;BR /&gt;	
		Column(dt, colList[i]) &amp;lt;&amp;lt; set name (Word(2, colList[i], "Lymphocytes/"))		
));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run parts of this code individually, here's what I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;line of code:&lt;/P&gt;&lt;P&gt;result in script log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colList[i]:
"Singlets/Live leukocytes/Lymphocytes/B cells/A+B+C-,Freq. of Parent"


contains(colList[i], "Singlets/Live leukocytes/Lymphocytes/"):
1

Word(2, colList[i], "Lymphocytes/"):
"iv"

Word(3, colList[i], "Lymphocytes/"):
" l"

Word(4, colList[i], "Lymphocytes/"):
"uk"

Word(9, colList[i], "Lymphocytes/"):
"f Par"&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Clearly, my delimiter isn't working the way I expect it to. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I originally tried to do Words(4, colList[i], "/") but that only gave me "B cells" since there is another / immediately after that. Unlike other programming languages, I don't know if there is a way to specify '4th word and then everything afterwards until the end' in JSL. I don't think this is possible so I changed the delimiter, thinking that would solve my problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for any advice!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 18:26:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78637#M36484</guid>
      <dc:creator>lakepotter</dc:creator>
      <dc:date>2018-10-10T18:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78651#M36486</link>
      <description>&lt;P&gt;Use "/" for the delimiter. Also, use the Words() function instead. You will get a list. You can then concatenate list items. In this case the new string will be list[5] || list[5].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pretty easy, eh?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 18:57:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78651#M36486</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-10-10T18:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78652#M36487</link>
      <description>&lt;P&gt;See Help &amp;gt; Scripting Index &amp;gt; Functions &amp;gt; Character &amp;gt; Words&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 18:58:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78652#M36487</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-10-10T18:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78656#M36488</link>
      <description>&lt;P&gt;What if I have an unequal number of list items? This one would be list[4]||" "||list[5] but if I have 6 items in my list and I want it to go to the end...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to pseudocode some for loops that go over N items but haven't gotten it yet.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:34:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78656#M36488</guid>
      <dc:creator>lakepotter</dc:creator>
      <dc:date>2018-10-10T19:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78657#M36489</link>
      <description>&lt;P&gt;Also, do you know why the original code doesn't work?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:34:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78657#M36489</guid>
      <dc:creator>lakepotter</dc:creator>
      <dc:date>2018-10-10T19:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78663#M36490</link>
      <description>&lt;P&gt;Use N Items( list ) to determine how many levels exist and take the ones from the end.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:52:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78663#M36490</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-10-10T19:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78664#M36491</link>
      <description>&lt;P&gt;The delimiter is a character, not a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also find regular expressions useful in this problem.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:53:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78664#M36491</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-10-10T19:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78706#M36521</link>
      <description>&lt;P&gt;One confusion is that the delimiter argument to the WORDS function means split this text if you find ANY of these characters.&lt;/P&gt;
&lt;P&gt;This approach may get you closer to what you want:&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;collist = {};
collist[1] = "Singlets/Live leukocytes/Lymphocytes/B cells/A+B+C-,Freq. of Parent";
collist[2] = "Singlets/Live leukocytes/Lymphocytes/Another Text";
collist[3] = "Singlets/Live leukocytes/Lymphocytes/Hello World";
remove_text = "Singlets/Live leukocytes/Lymphocytes/";
len_text    = length(remove_text);
for (i = 1, i &amp;lt;= nitems(collist), i++,
	start_pos = contains(colList[i], remove_text);
	if (start_pos,
		end_pos = start_pos + len_text;
		new_name = substr(collist[i], end_pos);
		show(new_name);
		Column(dt, colList[i]) &amp;lt;&amp;lt; set name (new_name);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 13:24:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78706#M36521</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-10-11T13:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion using word( ) function and specified delimiter</title>
      <link>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78741#M36536</link>
      <description>&lt;P&gt;OH! Okay, that also makes one of the examples in the scripting guide make MUCH more sense!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up using substr to my advantage! I'll post code after lunch!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 17:18:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Confusion-using-word-function-and-specified-delimiter/m-p/78741#M36536</guid>
      <dc:creator>lakepotter</dc:creator>
      <dc:date>2018-10-11T17:18:55Z</dc:date>
    </item>
  </channel>
</rss>

