Get number of occurrences of one string in another

Bob Sneidar bobs at twft.com
Thu Feb 23 14:48:55 EST 2012


Ohhh... sexier!

Bob


On Feb 23, 2012, at 10:10 AM, Ken Ray wrote:

> 
> On Feb 22, 2012, at 9:46 PM, Bob Sneidar wrote:
> 
>> only works for single characters. 
>> 
>> function substringCount pString, pChunk
>> replace pString with cr & pString & cr in pChunk
>> filter pChunk with pString
>> return the number of lines of pChunk
>> end substringCount
> 
> Here's one that works if you only have 1 character you're searching for:
> 
> 
>   split tString by tChar
>   put (the number of elements of tString) - 1 into tNumOccurrences
> 
> 
> Just offering another way to do it…
> 
> :D
> 
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/	
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list