• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: counting w*rds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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]


  • Prev by Date: OSX and Applet permissions
  • Next by Date: Pressing Filemaker's Continue Button
  • Previous by thread: Re: Pressing Filemaker's Continue Button
  • Next by thread: AppleScript & Mac OS X
  • Index(es):
    • Date
    • Thread