Evaluated proc mix_colours str { set out {}; set c [uniq [loffset [regexp -inline -all {\x03(\d+)(,(\d+))*} $str] 1 2]]; set c2 [shuf $c]; map [seq 0 [llength $c]] {x {set out [string map "[lindex $c $x] [lindex $c2 $x]" $str}}; . $out }