<?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 Re: Count number of occurrences of  specific words in a string in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49189#M27955</link>
    <description>&lt;P&gt;The documentation for JMP 13 does not indicate the LOC() function is only a JMP Pro function.&amp;nbsp; I would validate that by running the LOC() function example in the Scripting Index&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Show( Loc( [1 0 1 0 1 0] ) );
Show( Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, 2 ) );
Show(
	Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, [1 5] )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Jan 2018 22:32:27 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2018-01-03T22:32:27Z</dc:date>
    <item>
      <title>Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47053#M26812</link>
      <description>&lt;P&gt;Hello I'm looking to create a new column in my dataset that counts the number of times a specfic word appears in a string. The words are separated by "*" in each row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example table:&lt;/P&gt;&lt;P&gt;Animal List&lt;/P&gt;&lt;P&gt;1&amp;nbsp; dog*dog*cat*bird*dog&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;dog*dog*cat*bird*dog*dog&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Output should be&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Animal List&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Dog Count&lt;/P&gt;&lt;P&gt;1&amp;nbsp; dog*dog*cat*bird*dog&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;dog*dog*cat*bird*dog*dog&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can provide additional information if needed.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:32:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47053#M26812</guid>
      <dc:creator>agaddis</dc:creator>
      <dc:date>2017-11-10T15:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47062#M26817</link>
      <description>&lt;P&gt;Here is the formula for counting the number of times "dog" appears in a given column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Rows( Loc( Words( :Column 1, "*" ), "dog" ) )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="agaddis.GIF" style="width: 459px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8291i92EADDB618C58704/image-size/large?v=v2&amp;amp;px=999" role="button" title="agaddis.GIF" alt="agaddis.GIF" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 16:27:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47062#M26817</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-11-10T16:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47070#M26825</link>
      <description>Thank you!!</description>
      <pubDate>Fri, 10 Nov 2017 18:05:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47070#M26825</guid>
      <dc:creator>agaddis</dc:creator>
      <dc:date>2017-11-10T18:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47075#M26827</link>
      <description>&lt;P&gt;&amp;nbsp;How would this work for wildcard words? For example if dog had dog1 and another said dog2? I still would want it to count all of the dog words.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 19:27:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47075#M26827</guid>
      <dc:creator>agaddis</dc:creator>
      <dc:date>2017-11-10T19:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47077#M26828</link>
      <description>&lt;P&gt;The following formula will find all items with the string "dog" found in it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;wordList=words(st,"*");
count=0;for(i=1,i&amp;lt;=n items(wordList),i++,count=sum(count,contains(wordList[i],"dog")));
count;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Nov 2017 20:02:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/47077#M26828</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-11-10T20:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49186#M27953</link>
      <description>&lt;P&gt;Does the function Loc() exist only in JMP Pro?&lt;/P&gt;&lt;P&gt;Is there a way to count words or specific symbols in a string in regular JMP?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Here is the formula for counting the number of times "dog" appears in a given column&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Rows( Loc( Words( :Column 1, "*" ), "dog" ) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="agaddis.GIF" style="width: 459px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8291i92EADDB618C58704/image-size/large?v=v2&amp;amp;px=999" role="button" title="agaddis.GIF" alt="agaddis.GIF" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 22:20:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49186#M27953</guid>
      <dc:creator>l_yampolsky</dc:creator>
      <dc:date>2018-01-03T22:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49189#M27955</link>
      <description>&lt;P&gt;The documentation for JMP 13 does not indicate the LOC() function is only a JMP Pro function.&amp;nbsp; I would validate that by running the LOC() function example in the Scripting Index&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Show( Loc( [1 0 1 0 1 0] ) );
Show( Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, 2 ) );
Show(
	Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, [1 5] )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jan 2018 22:32:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49189#M27955</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-01-03T22:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49192#M27958</link>
      <description>&lt;P&gt;I can confirm that the Loc() function is not specific to JMP Pro. It is available in JMP.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2018 22:44:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/49192#M27958</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2018-01-03T22:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183547#M40293</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;What if there is no delimiter, e.g. I'd like to count how many "1" in a binary string 111001010?&lt;/P&gt;&lt;P&gt;How can I get the results like this?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 146px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15927i9874A1985ADE52A7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 16:09:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183547#M40293</guid>
      <dc:creator>KarenHuang</dc:creator>
      <dc:date>2019-03-04T16:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183550#M40296</link>
      <description>&lt;P&gt;Many ways to do this. Here's one.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ASCIIcode = blobtomatrix(chartoblob("1"),"int",1,"big")[1];  // 49
intermediate=blobtomatrix(chartoblob("0101111001010"),"int",1,"big")==ASCIIcode;
// intermediate=[0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0]
sum(intermediate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Line 1 is just a way to get the ASCII code for the ASCII character "1", returned in a matrix of 1 element.&lt;/P&gt;
&lt;P&gt;Line 2 is similar, but gets a bigger array and compares it to the desired code, resulting in the value in the Line 3 comment.&lt;/P&gt;
&lt;P&gt;Line 4 just adds up the elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 16:33:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183550#M40296</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-03-04T16:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183551#M40297</link>
      <description>&lt;P&gt;It looks like your data is numeric (base 10 already!) so you might need to use char(value) to get it back to a string representation.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 16:36:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183551#M40297</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-03-04T16:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183926#M40316</link>
      <description>&lt;P&gt;Please find one of the alternatives. Run the script to make a table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Table( "Counting Ones",
	Add Rows( 5 ),
	New Column( "Number",
		Numeric,
		"Continuous",
		Format( "Best", 17 ),
		Set Values( [111000010100001, 10101, 11111, 0, 101010101] ),
		Set Display Width( 132 )
	),
	New Column( "Count of One",
		Numeric,
		"Ordinal",
		Format( "Best", 12 ),
		Formula(
			Length( Char( :Number ) ) - Length(
				Substitute( Char( :Number ), "1", "" )
			)
		),
		Set Display Width( 102 )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2019 15:02:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/183926#M40316</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2019-03-05T15:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/184498#M40346</link>
      <description>&lt;P&gt;Two more alternatives.&lt;/P&gt;
&lt;P&gt;Use the&amp;nbsp;&lt;EM&gt;Words()&lt;/EM&gt; function with an empty string as delimiter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;b = 111001010;
N Row(Loc(Words(Char(b), ""), "1"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just with math (i.e. without converting number into string). For example:&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;b = 111001010;
Sum(Mod(Round(b / 10 ^ (Floor(Log10(b + 1)) :: 0)), 10));
&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 00:12:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/184498#M40346</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2019-03-07T00:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/184860#M40389</link>
      <description>&lt;P&gt;I like that last one! It looks like it will actually work up to 16 bits; 17 consecutive ones can't be stored in a double precision number. The :: operator makes a matrix, and there is a lot of matrix math after that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The words function might be the best one for general use...being easy to explain...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Mar 2019 19:18:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/184860#M40389</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-03-07T19:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/390113#M64025</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How would I change the function to count number of occurrences of both dog and cat?&lt;/P&gt;&lt;P&gt;I tried the Or, but this does not work properly.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Onjai&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 13:32:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/390113#M64025</guid>
      <dc:creator>Onjai</dc:creator>
      <dc:date>2021-06-03T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/390114#M64026</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Rows( Loc( Words( :Column 1, "*" ), "dog" ) ) +
N Rows( Loc( Words( :Column 1, "*" ), "cat" ) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Jun 2021 14:04:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/390114#M64026</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-06-03T14:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/724585#M90742</link>
      <description>&lt;P&gt;many thanks,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3605"&gt;@ian_jmp&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Actually, I did not expect the &lt;FONT face="courier new,courier"&gt;Length - Length&lt;/FONT&gt; to be 4x&amp;nbsp; faster than &lt;FONT face="courier new,courier"&gt;N rows(Loc ())...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/td-p/47053

dt = Open( "$SAMPLE_DATA/Wafer Stacked.jmp" );

	For Each Row(
		dt,
		dt:Lot_Wafer Label[] = Substitute( dt:Lot_Wafer Label, "1", "xxx_" )
	);

dt_long=dt &amp;lt;&amp;lt; Concatenate(dt,dt,dt,dt);

t0=hptime();
dt_long &amp;lt;&amp;lt;new column("new", set each value((Length(:Lot_Wafer Label)-Length(Substitute(:Lot_Wafer Label,"xxx","")))/3));
Write("via Length - Length:\!t",(hptime() - t0)/1000000,"s\!n");

t0=hptime();
dt_long &amp;lt;&amp;lt; new column("new", set each value(N Rows(loc(Words(:Lot_Wafer Label,"_"),"xxx"))));
Write ("via N Rows(Loc()):\!t", (hptime() - t0)/1000000,"s\!n");&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1708163913574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61189iCD451842AD413331/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1708163913574.png" alt="hogi_1-1708163913574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added this topic to&amp;nbsp;&amp;nbsp;&lt;LI-MESSAGE title="Tips and Tricks - best practice with JMP/JSL" uid="662686" url="https://community.jmp.com/t5/Discussions/Tips-and-Tricks-best-practice-with-JMP-JSL/m-p/662686#U662686" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 10:56:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/724585#M90742</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-02-17T10:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of occurrences of  specific words in a string</title>
      <link>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/724587#M90743</link>
      <description>&lt;P&gt;As I won't remember the&amp;nbsp; trick in 6 months - and as I don't want to invest the time to tell it every colleague, I tried to set up a custom function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions(
	New Custom Function(
		"test",
		"countWord",
		Function( {myString, myWord},
			If( Length( myWord ) &amp;gt; 0,
				Return( (Length( myString ) - Length( Substitute( myString, myWord, "" ) )) / Length( myWord ) ),
				Return( 0 )
			)
		),
		&amp;lt;&amp;lt;Description( "count words in a String" ),
		&amp;lt;&amp;lt;Example( Expr( test:countWord( "cat, dog, Dogs, cat, Cat", "cat" ) ) )
	)
);&lt;BR /&gt;&lt;BR /&gt;t0=hptime();&lt;BR /&gt;dt_long &amp;lt;&amp;lt; new column("new", set each value(test:countWord(:Lot_Wafer Label,"xxx")));&lt;BR /&gt;Write ("via custom function:\!t",(hptime() - t0)/1000000,"s\!n");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;unfortunately:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1708163680692.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61188iAEF93648BF9A5AB2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1708163680692.png" alt="hogi_0-1708163680692.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I have to adjust the custom function to make it as fast as the original version by&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/3605"&gt;@ian_jmp&lt;/a&gt;&amp;nbsp;?&lt;BR /&gt;[removing the If(...) helps a bit - but how to get it &amp;lt; 1s?]&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 10:10:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Count-number-of-occurrences-of-specific-words-in-a-string/m-p/724587#M90743</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-02-17T10:10:11Z</dc:date>
    </item>
  </channel>
</rss>

