var str = 'aa (xx, dd, ee), f gg (hh, dd, pp)'; str = str.replace(/(\(.*?\))/g, function (a){return a.replace(/,/g, '')}) alert(str);