Occurrences
Posted: Tue Jul 06, 2010 1:05 am
I would love a built in function that counts the number of occurrences of some string in a variable/field of text
Questions and answers about the LiveCode platform.
https://www.forums.livecode.com/
Code: Select all
function NbOccurInTexte psearch,pCont
put 0 into rNbOccurInTexte
put 0 into tCharsToSkip
repeat
put offset(psearch, pCont, tCharsToSkip) into UneOcc
if UneOcc = 0 then exit repeat
add UneOcc to tCharsToSkip
add 1 to rNbOccurInTexte
end repeat
return rNbOccurInTexte
end NbOccurInTexte