자바스크립트(javascript) 천단위 콤마 처리 (3자리마다 콤마 처리)
– 출처 : http://www.mredkj.com/javascript/nfbasic.html – * 문자열의 3자리마다 콤마를 추가해 주는 예제임과 동시에, 자바스크립트 정규식 치환의 좋은 예제이기도 하다. function addCommas(nStr){ nStr += ”; x = nStr.split(‘.’); x1 = x[0]; x2 = x.length > 1 ? ‘.’ + x[1] : ”; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, ‘$1’ + ‘,’ + ‘$2’); }… Read More »