This thread is a little old, but I had trouble finding a solution on this topic. Once I got into this it turned out to be more involved than I originally thought. So I have posted a link to what I did in case you find yourself in a similar situation.
As mentioned just splitting the string on word boundaries is pretty straight forward. The problem gets interesting when you start adding other constraints like beauty (uniform line lengths) and tags.