title: Regex replacements inside a StringBuilder
body: <p>I'm writing the contents of a text file to a StringBuilder and I then want to perform a number of find/replace actions on the text contained in the StringBuilder using regular expressions.</p>
  
  <p>I've run into a problem as the StringBuilder replace function is not capable of accepting regular expression arguments. </p>
  
  <p>I could use Regex.Replace on a normal string but I'm under the impression that this is inefficient due to the fact that two copies of the string will need to be created in memory as .net strings are immutable.</p>
  
  <p>Once I've updated the text I plan to write it back to the original file.</p>
  
  <p>What's the best and most efficient way to solve my problem?</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>In addition to the answer(s) below, I've found the following questions that also shed some light on my problem -</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/399798/memory-efficiency-and-performance-of-string-replace-net-framework">memory-efficiency-and-performance-of-string-replace-net-framework</a></li>
  <li><a href="https://stackoverflow.com/questions/287842/is-stringbuilder-replace-more-efficient-than-string-replace">is-stringbuilder-replace-more-efficient-than-string-replace</a></li>
  <li><a href="https://stackoverflow.com/questions/550702/at-what-point-does-using-a-stringbuilder-become-insignificant-or-an-overhead">at-what-point-does-using-a-stringbuilder-become-insignificant-or-an-overhead</a></li>
  </ul>