title: Regex to replace non escaped Quotes
body: <p>After having some trouble building a <code>json</code> string I discovered some text in my database containing double quotes. I need to replace the quotes with their escaped equivalents. This works:</p>
  
  <pre><code>function escape( $str ) {
      return preg_replace('/"/',"\\\"",$str);
  }
  </code></pre>
  
  <p>but it doesn't take into account that a quote may already be escaped. How can I modify the expression so that it's only true only for a non escaped character?</p>