• 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: looking to correct Smiles measuretext command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking to correct Smiles measuretext command


  • Subject: Re: looking to correct Smiles measuretext command
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 25 Jun 2011 19:12:58 -0500

On Jun 25, 2011, at 17:06, Robert Poland wrote:
I am looking for an Applescript command that will count characters, in a string, of over average length, like capitol letters, numbers, M and W and probably others.
______________________________________________________________________

Hey Bob,

You have the Satimage.osax installed don't you?  If so then this task should be pretty easy:

------------------------------------------------------------------------------------------------
# Find Handler -- Satimage.osax                                      MODIFIED 2010-09-25 : 00:00
------------------------------------------------------------------------------------------------
on fnd(findStr, dataSource, caseSensitive, allOccurrences, stringResult)
try
set findResult to find text findStr in dataSource ¬
case sensitive caseSensitive ¬
all occurrences allOccurrences ¬
string result stringResult ¬
with regexp
return findResult
on error
return false
end try
end fnd
------------------------------------------------------------------------------------------------

set str to "Now is the time for all good men to come to the aid of their country."
set foundString to fnd("[Na]+", str, true, true, true)
set stringCount to length of foundString

--> 3

I've turned case-sensitive on in the handler.

The brackets indicate a range: 

[a-z]       == lowercase letters
[A-Z]       == uppercase letters
[0-9]       == numbers
[aA17xY]    == miscellaneous
[[:punct:]] == punctuation
[!.,]       == partial punctuation

The Satimage.osax's default regular _expression_ syntax is Ruby, and this is a pretty good albeit incomplete guide:

http://userguide.icu-project.org/strings/regexp

Holler at me if you need any help with syntax.

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: looking to correct Smiles measuretext command
      • From: Robert Poland <email@hidden>
References: 
 >looking to correct Smiles measuretext command (From: Robert Poland <email@hidden>)

  • Prev by Date: looking to correct Smiles measuretext command
  • Next by Date: Re: looking to correct Smiles measuretext command
  • Previous by thread: looking to correct Smiles measuretext command
  • Next by thread: Re: looking to correct Smiles measuretext command
  • Index(es):
    • Date
    • Thread