Hi Jian,
Plese try the following:
ID=*IF(ID(1:2)=*STR(AA) then *STR(A_)+ID;ID(1:2)=*STR(BB) then *STR(A_)+ID)
You have not mentioned what if the ID does not start with AA or BB, if you take only ID in that case just do the following:
ID=*IF(ID(1:2)=*STR(AA) than *STR(A_)+ID;ID(1:2)=*STR(BB) than *STR(A_)+ID;ID)
Regards,
Kalyan.