var str='AAAA BBB CC DDDD BB CC [SDAC]'; alert(str+'\n'+str.replace(/(^|\s)\D{2,3}(?=\s|$)/g,'$1'+0));