title: Replace Links Location (href='...')
body: <p>I would like to replace the link location (of anchor tag) of a page as follows.</p>
  
  <p>Sample Input:</p>
  
  <pre><code>text text text &lt;a href='http://test1.com/'&gt; click &lt;/a&gt; text text
  other text &lt;a class='links' href="gallery.html" title='Look at the gallery'&gt; Gallery&lt;/a&gt;
  more text
  </code></pre>
  
  <p>Sample Output</p>
  
  <pre><code>text text text &lt;a href='http://example.com/p.php?q=http://test1.com/'&gt; click &lt;/a&gt; text text
  other text &lt;a class='links' href="http://example.com/p.php?q=gallery.html" title='Look at the gallery'&gt; Gallery&lt;/a&gt;
  more text
  </code></pre>
  
  <p>I hope I have make it clear. Anyway I am trying to do it with PHP and reg-ex. Would you please light me up with right.</p>
  
  <p>Thank you
  Sadi</p>