Remove more than two consecutive occurrence
<p>I have  a java <code>String</code> like this</p>

<pre><code>String str="&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P; Tannay Mnadal &amp;P;&amp;P;&amp;P;&amp;P;&amp;P;&amp;P; Tata"
</code></pre>

<p>I am trying to remove all <code>&amp;P;</code> where the consecutive occurrence is more than  two.</p>

<p>ie. any <code>function(str)</code> , will return <code>"&amp;P;&amp;P;"  Tannay Mnadal &amp;P;&amp;P; Tata</code></p>

<p>Any help will be appreciated.
Thanks</p>
