##Windows PowerShell, 138 Very ungolfed. $input|%{$x=$_-match'^ *' $l=$Matches[0].Length $x=$_-match' *$' $t=$Matches[0].Length ' '*$l+($_-replace'^ *| *$'-replace' ','@')+' '*$t}