title: PHP - preg_replace backreferencing
body: <p>I have big problems understanding how to use <code>preg_replace</code> with backreferencing.  </p>
  
  <p>I have a plain-text string and want to replace every link with the HTML syntax for a link. So "www.mydomain.tld" or "<a href="http://www.mydomain.tld" rel="nofollow">http://www.mydomain.tld</a>" or "<a href="http://mydomain.tld" rel="nofollow">http://mydomain.tld</a>" should be wrapped in an HTML a-tag. I have found a working function that does this online, but I want to understand how to do it myself.</p>
  
  <p>In the function I found, this is the replacement:</p>
  
  <pre><code>"\\1&lt;a href=\"http://\\2\" target=\"_blank\" rel=\"nofollow\"&gt;\\2&lt;/a&gt;"
  </code></pre>
  
  <p>I see some escaped quotation marks in there and these bits: <code>\\1</code> <code>\\2</code>.<br>
  According to the PHP documentation these are backreferences. But how do I use them, what do they do?  </p>
  
  <p>I found nothing about that in the spec, so any help would be greatly appreciated!</p>