title: Have trouble understanding capturing groups and back references
body: <p>Wishing to put some order into my knowledge of regular expressions I decided to go through a book about them, <em>Introducing Regular Expressions</em>. And I know it's silly but one of the introductory examples doesn't make sense to me.</p>
  
  <pre><code>(\d)\d\1
  </code></pre>
  
  <p>Sample text:</p>
  
  <pre><code>123-456-7890
  </code></pre>
  
  <p>(should capture the first number, <code>123</code>)</p>
  
  <p>Can anyone explain what is going on in here?</p>
  
  <p>As far as I can figure out, the first <code>\d</code> captures the number 123. The <code>\1</code> backreferences (marks) the group for later use. The parenthesis limit the scope of the group. But what does the second <code>\d</code> does?</p>
  
  <p>Simple explanation, like to a small child or a golden retriever are prefered.</p>