The (Unofficial) BBEdit Hints Weblog
Applescript: Select a sentence

Today I’m going to show a BBEdit Applescript which selects a sentence.

The trick to this script is that it defines a sentence as “a blurb of text ending - and/or starting with - a period and two spaces”. However, there is some disagreement on that point.

A sentence must also start with a number or letter.

Having said that, the “two spaces after a period” gives our script a clear delimiter on where a sentence ends - instead of thinking the sentence ends when I refer to my friend, Dr. Worm. (Just looking for a period would have ended it on “Dr”, not “Worm”.

Regardless of the contentious topic, this makes a great snippet to show off scripting the find command.

Find this script on a Github gist, or below (if you have Javascript enabled).