Evaluated set brr {b e r r y}; set fag [regsub -all {(f|a|g)} [berry] [invert " "]]; set out ""; set cur 0; for {set i 0} {$i < [string length $fag]} {incr i} { if {[string index $fag $i] eq ":"} {append out [lindex $brr $cur]} {append out [string index $fag $i]};. $out  }