So here is the idea.
1) Start line
"Hello World, how are you?"
2) Return line, but not including final special characters
"uoy era woh ,dlroW olleH?"
3) Inverse words in a string
"you are how ,World Hello?"
4) Create an iterator (pointer, index, whatever you use) at the beginning and end of the line, increase / decrease each iterator until you hit non-words. Without words, I mean a space or a special character. Thus, in this case, the incrementing iterator will first encounter a space between “you” and “there”, while the decreasing iterator will encounter an empty space between the “world” and “Hello”, as shown below.
"you are how ,World Hello?" ^ ^
5) If there are no special characters, continue if you press the special character. Flip everything between iterators, including the characters they point to. The following shows when this happens.
"you are how ,World Hello?" ^ ^
6) And now we see the result of reversing.
"you are, woh World Hello?"
Edit due to comment from johnchen902
7) Now we will reverse the substring between these iterators, excluding the special character found in step (5).
"you are, how World Hello?"
8) return to step (5).
I haven't encoded this yet, and it was a bit hard to explain, but I hope you understand