On Mar 19, 2007, at 9:28 AM, Elie Boulos wrote:
I need to find the number of instances of an arbitrary string
in a single text file, is this possible through AppleScript?
Search matches doesn't have such a number.
For example, I need to find out the count of the word 'and' in
a text containing "He bought a hammer and a nail and a tape and
a screw driver" (that's 3 and's)
You can request that the matches are returned to you, then count
them. For example:
tell application "BBEdit"
set _findResults to find "and" searching in {document 1} options
{returning results:true}
set _matchCount to 0
if found of _findResults then
set _matchCount to count items of found matches of _findResults
end if
display alert _matchCount
end tell
Jim
--
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>