Took me a little bit to figure this one out.

The reason why it's excluding the first and last characters, is because they weren't included in your back-reference. $regsub replaces the entire substring that is matched, including characters that fall outside of the back-reference. Since you replaced the entire substring with only the characters from the back-reference, the first and last characters got "written over".


Well. At least I won lunch.
Good philosophy, see good in bad, I like!