title: Javascript Replace with variable in string with Regular Expression
body: <p>I want to replace a lot of keywords in string with pre-defined variables, samples as below,
  but now $1 only shows variable name, not variable content, any one can help me, please!!!</p>
  
  <p>Correct:</p>
  
  <blockquote>
    <p>1111{t:aa}<br>
    2222{t:bb}<br>
    3333{t:cc}  </p>
  </blockquote>
  
  <p>To:</p>
  
  <blockquote>
    <p>1111Test1<br>
    2222Test2<br>
    3333Test3</p>
  </blockquote>
  
  <p>Not:</p>
  
  <blockquote>
    <p>1111aa<br>
    2222bb<br>
    3333cc</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>var aa = "Test1";
  var bb = "Test2";
  var cc = "Test3";
  var str_before = "1111{t:aa}\n2222{t:bb}\n3333{t:cc}";
  var str_after = str_before.replace(/\{t:\s*(\w+)\}/g, "$1");
  alert(str_before+"\n\n"+str_after);
  </code></pre>