<p>I want to check for duplicated words right next to each other, but even if there is punctuation in between.</p>
<p>For example:</p>
<pre><code>Vivamus Vivamus diam, diam, Vivamus Vivamus diam, diam Vivamus
</code></pre>
<p>There should be four distinct hits here.</p>
<p>I can't figure out why this isn't working. Why? What should the correct code be?</p>
<pre class="lang-none prettyprint-override"><code>(\w*(?:[ ,\.])*?)\1
</code></pre>
<hr />
<p><em>PS: This is</em> <em><strong>not</strong></em> <em>necessarily for the Perl engine.</em></p>

The
```
(?:
```
is a non-capturing parenthesis, meaning it won't store the matches.  You will need to use capturing parentheses.
```
```
(\w+)\W+\1
```
```