title: Tcl regsub used with subst produces unexpected result
body: <p>Edit: 
  I was trying to replace "xor_in0" with "xor_in[0]" and "xor_in1" with "xor_in[1]" for a given str parameter. Here "xor_in0", "xor_in1" is parameter passed in and I represent it as "key", and "xor_in[0]", "xor_in[1]" is the value parameter stored in an array. Notice the point here is to replace every "key" in "str" with "value" . Here is my testing code:</p>
  
  <pre><code>set str "(xor_in0^xor_in1)"
  set str1 "xor_in0^xor_in1" # another input
  set key "xor_in0"
  set value "xor_in\[0\]"
  set newstr ""
  set nonalpha  "\[^0-9a-zA-Z\]"
  regsub -all [subst {^\[(*\]($key)($nonalpha+)}] $str [subst -nobackslashes {$value\2}] newstr
  puts $newstr
  </code></pre>
  
  <p>But somehow it doesn't work... I also tried to remove [subst ...] and it still failed to match anything. This is somehow against my knowledge of regular expression. Please help.</p>