title: String replace: multiple replace is not working in JQuery
body: <p>I have a string and some text (name attr) should be replaced with dynamic text. For example 
  <code>options[team_member][0][name]</code> will be replaced with <code>options[team_member][1][name]</code>.</p>
  
  <p>What far i did:</p>
  
  <pre><code>    var current = 1;
  
      var block = jQuery('#contents').html();
      var replace_str = 'options[team_member]['+(current-1)+']';
      var replace_with = 'options[team_member]['+(current)+']';
  
      /* replace only first match */
      var rep_block = block.replace(replace_str,replace_with);
  
      /* replace nothing */
      // var rep_block = block.replace(/replace_str/g,replace_with);
  
      /* replace nothing */
      // var rep_block = block.replace(/(replace_str)/g,replace_with);
  
      alert(rep_block);
  </code></pre>
  
  <p>Please check full code in <a href="http://jsfiddle.net/itskawsar/2QFUw/" rel="nofollow">jsFiddle</a></p>
  
  <p>I cannot find the way how can i solve this. Please help me. Thanks in advance.</p>