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