title: Search and replace all in javascript/nodejs
body: <p>My replace all function is as below, it is in commonHelper.js file</p>
  
  <pre><code>exports.replaceAll = function (find, replace, str) {
    return str.replace(new RegExp(find, 'g'), replace);
  }
  </code></pre>
  
  <p>Then I do following </p>
  
  <pre><code>var commonHelper = require('./commonHelper');
  var html_body = commonHelper.replaceAll('[[username]]', user_row.username, template_row.message_body);
  html_body = commonHelper.replaceAll('[[forgot_pass_link]]', forgot_pass_link, html_body);
  </code></pre>
  
  <p>this is not properly replacing the [[key]] parts here. What should I change to fix this?</p>