title: Replace ' with \' in a string
body: <p>I have a string:</p>
  
  <pre><code>s = r"This is a 'test' string"
  </code></pre>
  
  <p>I am trying to replace <code>'</code> with <code>\'</code> so the string will look like below:</p>
  
  <pre><code>s = r"This is a \'test\' string"
  </code></pre>
  
  <p>I tried <code>s.replace("'","\'")</code> but there is no change in result. It remains the same.</p>