Re: counting w*rds
Re: counting w*rds
- Subject: Re: counting w*rds
- From: "Marc K. Myers" <email@hidden>
- Date: Wed, 23 May 2001 09:43:52 -0400
- Organization: [very little]
>
On 5/21/01 10:03 PM, Ehsan Saffari <email@hidden> wrote:
>
>
>and on a similar note, how to count the occurances of a substring in a
>
>string?
set theStrng to "I saw the bee. Did the bee see me? How could that be?"
set x to countSub(theStrng, "be")
on countSub(theText, theSub)
set occCnt to 0
set strLng to length of theSub
set theOffset to the offset of theSub in theText
repeat until theOffset is 0
set occCnt to occCnt + 1
set theText to text (theOffset + strLng) thru (count theText) of theText
set theOffset to the offset of theSub in theText
end repeat
return occCnt
end countSub
--> 3
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[5/23/01 9:41:43 AM]