¾È±Ô °øºÎ¹æ

Javascript & JQuery & CSS > example - ÄÞ¸¶Âï±â, ÄÞ¸¶ Ç®±â

µî·ÏÀÏ : 2019-09-19 15:20 Á¶È¸¼ö : 53,664


str1		= "-123456.789";
str2		= "12,345.789";

alert(comma(str1));
alert(uncomma(str2));
//ÄÞ¸¶Âï±â
function comma(str) {
    str = String(str);
    return str.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
}

//ÄÞ¸¶Ç®±â
function uncomma(str) {
    str = String(str);
    return str.replace(/[^\d]+/g, '');
}

°á°ú1  : -123,456.789
°á°ú 2 : 123456789

 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.