If they are all grouped together:
code:
StringObj.replace(/(.*)(A*)(.*)/i,"$1$3$2);
I personally can't think of a way to get all of them on the end however... This code might work but t is untested...
code:
var StringObj;
while(RegExp(".*A+[^A]+A*$","gi").exec(StringObj)){
StringObj.replace(/(.*?)(A*)(.*)/i,"$1$3$2);
}