//用javascript,核心就以下两行代码
str = str.replace(/(\w)\1[2,]/g,'$1$1');
str = str.replace(/(\w)\1(\w)\2/g,'$1$1$2');