set o ## gets stdin s while {$s>""} {append o [expr "{$s}<{ !}||{# #}<{$s}?{ }:{#}"] set s [regsub . $s ""]} puts $o