var string = '5, 5, 2, 3, 3, 3',
count2 = 0, count3 = 0,
count4 = 0, count5 = 0,
result = string.match(/\d/g);
for(var i = 0; i < result.length; i++) switch(result[i]){
case '2': count2++; break;
case '3': count3++; break;
case '4': count4++; break;
case '5': count5++; break;
};
alert('2: '+count2+', 3: '+count3+', 4: '+count4+', 5: '+count5);