title: How can I perform an equivalent of php str_replace in JavaScript?
body: <p>How can I perform a case-sensitive string replacement in JavaScript? I am looking for something similar to PHP's <code>str_replace</code>.</p>
  
  <pre><code>var text = "this IS some sample text that is going to be replaced";
  var new_text = replace_in_javascript("IS", "is not", text);
  document.write(new_text);
  </code></pre>
  
  <p>should give</p>
  
  <pre><code>this is not some sample text that is going to be replaced
  </code></pre>
  
  <p>I would like to replace all the occurences.</p>