Determining number of occurrences

Doug Easterbrook doug at artsman.com
Fri Dec 19 14:03:35 EST 2014


hi Andrew/Jean Marc


Jan Marc's solution is good for single characters -- fails if you are looking for patterns like   --* or such.

TMobjs external (again free) has a replace function where one of the parameters is the number of times the replacement happened.

makes it generic.


or change JM's solution to


template = '--*'
Calculate OccNb as len(Mystring)-len(replaceall(Mystring, template,'')*length(template)



Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 536-1205    Fax (403) 536-1210

> On Dec 19, 2014, at 11:34 AM, Jean Marc Azerad <azerad.jm at wanadoo.fr> wrote:
> 
> Calculate OccNb as len(Mystring)-len(replaceall(Mystring,'.','')
> 
> Not tried but should work...
> 
> 
> 
>> Le 19 déc. 2014 à 18:59, Andrew Stolarz <stolarz at gmail.com> a écrit :
>> 
>> Hello,
>> 
>> What is the best way to determine the number of occurrences within a string?
>> 
>> ie. count number of times a period '.' is in a string.
>> 
>> 
>> 
>> Andrew
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com



More information about the omnisdev-en mailing list