Evaluated set brr {b e r r y}; set cur 0; set fag [regsub -all {(f|a|g)} [berry] [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}};. $out