title: Postgres Escape Single and Double Quotes in Text Field
body: <p>I may have an odd request.  I'm not finding any help via Google.</p>
  
  <p>I am using the DbVisualizer Pro 10.0.15 gui tool connected to a PostgreSQL db. </p>
  
  <p>I need to create a csv file from a database table.  I select the records I need in a query then export the results to a .csv file.  I can do that easy.</p>
  
  <p><code>select note from notes;</code></p>
  
  <p><code>highlight all results records &gt;&gt; right-click &gt;&gt; select export &gt;&gt; choose csv</code></p>
  
  <p>Some of the records have both single and/or double-quotes in the content.</p>
  
  <p>The person receiving this file needs to upload the csv file into another system.  They are stating that these single and double-quotes in the content will not work in their upload. I've been asked to escape these quotes.  They want to keep them in the content, but have them appear in the field with the backslash escape character, i.e: <code>it is John's ball</code> would show in the csv file as: <code>it is John\'s ball</code>.  The same for dbl-quotes.</p>
  
  <p>I could probably do this with a search-and-replace function in a text editor after creating the csv file, but I'd like to think this can be done via sql.</p>
  
  <p>I've tried playing with the <code>regexp_replace()</code> function.</p>
  
  <p><code>select regexp_replace(note, '"', '\"') as notes from notes</code> works on the dbl-quotes, but I'm not having any luck on the single quotes.</p>
  
  <p>Help?  Is there a way to do this?</p>