AOL interview question

How would you write an algorithm to truncate text, accounting for spaces and punctuation?