title: Replace $ with \$ in string for Dart consumption (not raw)
body: <p>This seems like an easy question, but I can't figure it out.</p>
  
  <p>I have a string in a JSON object that is generated from another language which contains escape characters and dollar signs (which should be interpreted as dollar signs).  When I use this string in Dart, it complains about the $ because it thinks it is a variable.  Adding the r in front of the string to interpret the string as raw is not sufficient because then it doesn't interpret any of the other escape characters.</p>
  
  <p>For example, given the following string:</p>
  
  <pre><code>line 1 costs $250 and\nline 2 costs $300
  </code></pre>
  
  <p>I need to convert it to this so that I can work with it in Dart:</p>
  
  <pre><code>line 1 costs \$250 and\nline 2 costs \$300
  </code></pre>
  
  <p>I also want to create a test for this condition for my converter.</p>
  
  <p>I have tried the following without luck:</p>
  
  <pre><code>String s2 = s1.replaceAll(RegExp(r'\$'),r'\$');
  </code></pre>
  
  <p>and for the test:</p>
  
  <pre><code>expect(s1, contains('\$'));
  expect(s2, contains('\\\$'));
  </code></pre>
  
  <p>Any suggestions?</p>