That is true. If it's not a character count that is needed, this would break words. DISTINCT VALUES, GET TEXT KEYWORDS, and Count in array would help in that case.
> On Apr 9, 2019, at 3:37 PM, Charles Miller via 4D_Tech <4d_tech@lists.4d.com> > wrote: > > That will not work, as you would also change then, therefore etc. I > did not think it 100% through, but putting in an array would solve the > problem as you could see if position = search word and only increment > when iot did. You would also have to decide is The = the etc > > Regards > Chuck > > On Tue, Apr 9, 2019 at 4:29 PM Keith Culotta via 4D_Tech > <4d_tech@lists.4d.com> wrote: >> >> ...and this. It's probably slower than using Position, but I'd have to test >> to be sure. (3 Lengths and 1 Replace string) >> >> C_LONGINT($count;$len1;$len2;$lenFind) >> >> $string:="This message and any attached documents contain information which >> maybe confidential, subject to privilege or exempt from disclosure >> underapplicable law. These materials are intended only for the use of >> theintended recipient. If you are not the intended recipient of >> thistransmission, you are hereby notified that any distribution,disclosure, >> printing, copying, storage, modification or the taking ofany action in >> reliance upon this transmission is strictly prohibited.Delivery of this >> message to any person other than the intendedrecipient shall not compromise >> or waive such confidentiality,privilege or exemption from disclosure as to >> this communication.tf" >> >> $len1:=Length($string) >> $find:="the" >> $lenFind:=Length($find) >> $string2:=Replace string($string;$find;"";*) // optional * >> $len2:=Length($string2) >> >> $count:=$len1-$len2/$lenFind >> >> ALERT(String($count)) >> >> Keith - CDI >> >>> On Apr 9, 2019, at 3:05 PM, Charles Miller via 4D_Tech >>> <4d_tech@lists.4d.com> wrote: >>> >>> Not sure what you are really asking for. I think you have to roll your >>> own in any case if you have text as follows: >>> >>> $string:="this is a test of the find in string. in case you missed the >>> point." >>> >>> To find "the" >>> There are multiple ways, one is to parse the text into arrays based up >>> words and find in array. There seems to be a new command in 17 r >>> release that will do the parse for you >>> >>> The second way is to do a position inside a repeat loop >>> c_Longint($pos_l;$start_l;$Count_L) >>> $start_l:=0 >>> $Count_L:=0 >>> repeat >>> $pos_l:=position("the";$string;$start_L) >>> if($pos_l>0) >>> $Count_L:=$Count_L+1 >>> $strart_L:=$pos_L+1 >>> end if >>> until($Pos_L<1) >>> >>> You should be able to change the code to use find in array. I might >>> sort the array first >>> Hope this helps >>> >>> Regards >>> Chuck >>> On Tue, Apr 9, 2019 at 3:39 PM Peter Mew via 4D_Tech >>> <4d_tech@lists.4d.com> wrote: >>>> >>>> Hi >>>> Is there a 4D command that will count the number of occurences of >>>> character, in string >>>> thanks >>>> -pm ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************