title: How do I replace all spaces, commas and periods in a variable using javascript
body: <p>I have tried <code>var res = str.replace(/ |,|.|/g, "");</code> and <code>var res = str.replace(/ |,|.|/gi, "");</code>. What am I missing here?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var str = "Text with comma, space, and period.";
  var res = str.replace(/ |,|.|/g, "");
  document.write(res);</code></pre>
  </div>
  </div>
  </p>