How To Reverse The String With Preserving The Position Of Spaces?

How To Reverse The String With Preserving The Position Of Spaces?