you can also use the following code in javascript if you are not sure for the second instance would replace or not.
var tmp = "AABAA";
var sNewStr = '';
var newStringArray = new Array();
newStringArray = tmp.split('AA');
sNewStr = newStringArray .join('A');
commented on Jul 21 2011 10:39PM