You need more "logic" .... more more logic. Not just a simple replace and a bunch of loops!

First, split the long string into an array of strings, each item containing only one word (no spaces...