Re: counting w*rds
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