...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
>> **********************************************************************
> 
> 
> 
> -- 
> -----------------------------------------------------------------------------------------
> Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
> Informed Solutions, Inc.
> Brookline, MA 02446 USA Registered 4D Developer
>       Providers of 4D, Sybase & SQL Server connectivity
>          http://www.informed-solutions.com
> -----------------------------------------------------------------------------------------
> This message and any attached documents contain information which may
> be confidential, subject to privilege or exempt from disclosure under
> applicable law.  These materials are intended only for the use of the
> intended recipient. If you are not the intended recipient of this
> transmission, you are hereby notified that any distribution,
> disclosure, printing, copying, storage, modification or the taking of
> any action in reliance upon this transmission is strictly prohibited.
> Delivery of this message to any person other than the intended
> recipient shall not compromise or waive such confidentiality,
> privilege or exemption from disclosure as to this communication.
> **********************************************************************
> 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
> **********************************************************************

**********************************************************************
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
**********************************************************************

Reply via email to