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