------------------------------------------------------------------------------------------------
# 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:
Holler at me if you need any help with syntax.