javascript 세자리마다 콤마(,) 찍기

script 2010. 2. 18. 15:45
//콤마찍기
function numberFormat(num) {
	var pattern = /(-?[0-9]+)([0-9]{3})/;
	while(pattern.test(num)) {
		num = num.replace(pattern,"$1,$2");
	}
	return num;
}

//콤마제거
function unNumberFormat(num) {
	return (num.replace(/\,/g,""));
}
: