title: PHP preg_replace \\'
body: <p>I am trying to replace one or more backslashes followed by a quote. For example, how can I replace all instances of <code>\\'</code> with <code>'</code>, <code>\\\\'</code> with <code>'</code>.</p>
  
  <p><strong>Sample IO:</strong> </p>
  
  <p><code>It can\\\\\\\\\\\\\\'t hurt.</code> =>  <code>It can't hurt</code></p>
  
  <p><code>It can\\'t hurt.</code> =>  <code>It can't hurt</code></p>
  
  <p>also</p>
  
  <p><code>It can\'t hurt.</code> =>  <code>It can't hurt</code>
  Sample code I am trying to begin with</p>
  
  <pre><code>&lt;?php
  $pattern = '/[/{2,}]/';
  $replacement = '\'';
  $subject = 'It can\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'t hurt';
  echo preg_replace($pattern, $replacement, $subject, -1 );
  ?&gt;
  </code></pre>