<?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: Searching and counting substrings within a text field in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636518#M83463</link>
    <description>&lt;P&gt;Substitute does allow you to use &amp;lt;&amp;lt; IGNORECASE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
Substitute("Apple,APPLE,apple", "apple", "orange", &amp;lt;&amp;lt;IGNORECASE);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1685390944820.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53198iE39BEF07F75166C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1685390944820.png" alt="jthi_0-1685390944820.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/list-functions.shtml?os=win&amp;amp;source=application#ww2490257" target="_blank"&gt;https://www.jmp.com/support/help/en/17.0/#page/jmp/list-functions.shtml?os=win&amp;amp;source=application#ww2490257&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 20:09:34 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-05-29T20:09:34Z</dc:date>
    <item>
      <title>Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636488#M83458</link>
      <description>&lt;P&gt;JMP Add-in did a great job importing hundreds of MSWord documents into a table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I &lt;FONT face="arial,helvetica,sans-serif"&gt;have&lt;/FONT&gt; a column called "comment (original)" that I wish to count the number of "no comment" phrases.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use the formula,&lt;/P&gt;&lt;P&gt;&lt;EM&gt;N Rows(&lt;BR /&gt;Loc(&lt;BR /&gt;Words( :"comment (white space collapsed)"n, " " ),&lt;BR /&gt;"comments"&lt;BR /&gt;)&lt;BR /&gt;)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;it returns the number of occurrences for the term "comments".&amp;nbsp; However, the Loc function will not accept "no comments" as an argument. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Rows(
	Loc(
		Words( :"comment (white space collapsed)"n, " " ),
		"comments"
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;JMP v17.1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Interestingly, the formula works correctly if the comment column was recoded to collapse whitespace.&amp;nbsp; Not sure why.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Any thoughts or assistance would be appreciated!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Thank you.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 00:01:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636488#M83458</guid>
      <dc:creator>Onjai</dc:creator>
      <dc:date>2023-06-11T00:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636497#M83459</link>
      <description>&lt;P&gt;If you want to use Loc, you have to figure out other way of splitting the string into a list than Words(). With Words() you won't get "no comments" string in the list as those will be split into "no" and "comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One option would be to substitute all "no comments" with empty strings, then compare length of the original and new string and divide with the length of comparison string. Something like this might work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

str = "Friday, December 9, 2022 10/19/2022 9:37 AM flagged with a comment 10/21/2022 6:15PM : no comment 11/15/2022 1:03 PM 3: no comments 11/16/2022 11:06 AM 4: no comments 11/18/2022 2:49 PM : no comments 11/30/2022 3:52 PM : comments 12/09/2022 9:07 AM : no comment";
str_to_search = "no comment";
new_str = Substitute(str, str_to_search, "");

matches = (Length(str) - Length(new_str)) / Length(str_to_search);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 May 2023 18:36:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636497#M83459</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-29T18:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636506#M83460</link>
      <description>&lt;P&gt;Interesting approach.&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I ran the script, it returned a count of 5.&amp;nbsp; Three (3) of the cases are "no comment&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;/FONT&gt;" and two (2) are "no comment".&lt;/P&gt;&lt;P&gt;Not sure if or how the Substitute function allowed the plural? i.e. str_to_search = "no comment". &amp;nbsp; Also the Length function would have been 1 more for the plural "no comments".&lt;/P&gt;&lt;P&gt;I am curious to know if there is another approach to validate this?&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 19:29:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636506#M83460</guid>
      <dc:creator>Onjai</dc:creator>
      <dc:date>2023-05-29T19:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636509#M83461</link>
      <description>&lt;P&gt;I expected that no comment and no comments would be the same and because no comment is in both of those, the replacement will work (for no comments it will just leave the s there). If you need more complex replacements Regex would be a good option while using GLOBALREPLACE.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 19:36:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636509#M83461</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-29T19:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636512#M83462</link>
      <description>&lt;P&gt;Got it.&amp;nbsp; I saw that in the script when hovering over the variables.&amp;nbsp; This works.&amp;nbsp; The only issue is that it is case sensitive.&lt;/P&gt;&lt;P&gt;I may run this as a column formula.&amp;nbsp; Adding 2 more columns for the case types and sum the columns by row.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(Length( :"comment (white space collapsed)"n ) - Length(
	Substitute( :"comment (white space collapsed)"n, "no comment", "" )
)) / Length( "no comment" )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you.&amp;nbsp; I'm back in business.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Onjai.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 19:59:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636512#M83462</guid>
      <dc:creator>Onjai</dc:creator>
      <dc:date>2023-05-29T19:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Searching and counting substrings within a text field</title>
      <link>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636518#M83463</link>
      <description>&lt;P&gt;Substitute does allow you to use &amp;lt;&amp;lt; IGNORECASE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
Substitute("Apple,APPLE,apple", "apple", "orange", &amp;lt;&amp;lt;IGNORECASE);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1685390944820.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/53198iE39BEF07F75166C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1685390944820.png" alt="jthi_0-1685390944820.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/list-functions.shtml?os=win&amp;amp;source=application#ww2490257" target="_blank"&gt;https://www.jmp.com/support/help/en/17.0/#page/jmp/list-functions.shtml?os=win&amp;amp;source=application#ww2490257&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 20:09:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Searching-and-counting-substrings-within-a-text-field/m-p/636518#M83463</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-05-29T20:09:34Z</dc:date>
    </item>
  </channel>
</rss>

