title: preg_replace to change url from relative to absolute
body: <p>My PHP code is:</p>
  
  <pre><code>$string = preg_replace('/(href|src)="([^:"]*)(?:")/i','$1="http://mydomain.com/$2"', $string);
  </code></pre>
  
  <p>It work with:</p>
  
  <pre><code> - &lt;a href="aaa/"&gt;Link 1&lt;/a&gt; =&gt; &lt;a href="http://mydomain.com/aaa/"&gt;Link 1&lt;/a&gt;
   - &lt;a href="http://mydomain.com/bbb/"&gt;Link 1&lt;/a&gt; =&gt; &lt;a href="http://mydomain.com/bbb/"&gt;Link 1&lt;/a&gt;
  </code></pre>
  
  <p>But not with:</p>
  
  <pre><code>- &lt;a href='aaa/'&gt;Link 1&lt;/a&gt;
  - &lt;a href="#top"&gt;Link 1&lt;/a&gt; (I don't want to change if url start by #).
  </code></pre>
  
  <p>Please help me!</p>