This script should do the trick: repeat while (char 1 of myString = space) delete char 1 of myString end repeat repeat while (char -1 of myString = space) delete char -1 of myString end repeat