hmm... did you test that out, benkillin?
I tested a simplified version:
<?php
$str = "HelloaaaaaWorld!";
$str = ereg_replace("([a]{2})", "\1", $str);
echo $str;
?>
and interestingly a hex dump of the result:
48 65 6C 6C 6F 01 01 61 57 6F 72 6C 64 21
which means that there are two mysterious 0x01 characters, and only 1 'a' character remained.
Doesnt seem to work then.
I thought superwormy's code would work, but for some reason it isnt.