title: Matching the same word twice with a regular expression, not caring what the word is
body: <p>Take the following input:</p>
  
  <pre><code>foo.foo aefhiuafhiauefheiauh bar.bar jgoeiajgoieajogiae baz.foo ogiejaogijaeoigjea
  </code></pre>
  
  <p>Say I want to match <code>x.x</code> where x is the same both sides of the dot. So I don't want to match <code>x.y</code>. So with the example input, I'd get <code>foo.foo</code>, <code>bar.bar</code> and not <code>baz.foo</code></p>
  
  <p>What I want to do is something like</p>
  
  <pre><code>(\w+)\.$1
  </code></pre>
  
  <p>But of course that doesn't work.</p>
  
  <p>Is this possible in any sane way with a regex, or should I be matching <code>x.y</code> and handling the comparison of <code>x</code> and <code>y</code> in code?</p>
  
  <p>For the sake of the question, assume I'm using the Javascript regex engine.</p>