Given a string that contains characters, spaces (0x20) and tabs (0x09) where a tab displays as moving to the next tabstop (which are equally spaced N characters apart)
Problem #1 :
change multiple spaces to the correct number of tabs, so that the VISUAL display remains the same
Problem #2 :
change single or multiple tabs to the correct number of spaces , so that the VISUAL display remains the same
These are two different transformations that could be applied to the text
Because the visual display needs to remain the same, any given tab may need to be converted to anywhere from 1 to N spaces, and vice-versa… So it it not a simple replaceall