• 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: Greg Strange <email@hidden>
  • Date: Tue, 22 May 2001 17:53:27 -0500

on 5/22/01 12:03 AM, Ehsan Saffari at email@hidden wrote:

> There are many characters that AS considers a word:
>
> set x to "****"
> count words of x -->4
>
> how can I count the words in a string while
> ignoring a special character like "*" using vanilla AS:
>
> set x to "****"
> count words of x -->me needs 1
>
> and on a similar note, how to count the occurances of a substring in a
> string?
>
> thanks for any hints

You could always do something like this:

set mySentence to "This is a great sentence but it may have some special
characters like ****."

set AppleScript's text item delimiters to space
set wordList to the text items of mySentence

set wordCount to the count of items in wordList
(*14*)

set wordCount2 to the count of words in mySentence
(*17*)


Hope that helps.

Greg Strange
--
If you liked WKRP, you'll hate Mouthful of Liquor.
Not for the faint of smart,
www.mouthfullofliquor.com


  • Prev by Date: Re: Mounting disk before continuing
  • Next by Date: Re: Installer Observer Substitute, or an applescript workaround
  • Previous by thread: Re: counting w*rds
  • Next by thread: Re: counting w*rds
  • Index(es):
    • Date
    • Thread