Get number of occurrences of one string in another
jhj at jhj.com
Wed Feb 22 21:44:50 CST 2012
The offset() function has a third parameter: chars to skip. So if you call offset in a loop with the third param set to the previous result, and count loops until it returns 0, Bob's your uncle.
On Feb 22, 2012, at 7:37 PM, Andrew Kluthe wrote:
> function substringCount pChar, pString
> put 0 into theCount
> repeat for each char theChar in pString
> if theChar is pChar then
> add 1 to theCount
> end if
> end repeat
> return theCount
> end substringCount
> Would work out nicely if there is not built in function for this.
> View this message in context: http://runtime-revolution.278305.n4.nabble.com/Get-number-of-occurrences-of-one-string-in-another-tp4412675p4412707.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode