//------------- ----------------------------------
//Delete thousandth points.
//------------------------------------------------ --
function removeComma(number) {
var num = number.replace(new RegExp(",","g"),"");
if(/^[- ]?[0 -9] (.[0-9] )?$/.test(num)) {
return num;
} else {
return number;
}
}
//---------------------------------------------
//Add thousandths.
//---------------------------------------------
function addKannma(number) {
var num = number.replace(new RegExp(",","g"),"");
// Positive and negative sign processing
var symble = "";
if(/^([- ]).*$/.test(num)) {
symble = num.replace(/^([- ]).*$ /,"$1");
num = num.replace(/^([- ])(.*)$/,"$2");
}
if(/^[ 0-9] (.[0-9] )?$/.test(num)) {
var num = num.replace(new RegExp("^[0] ","g"),"") ;
if(/^./.test(num)) {
num = "0" num;
}
var decimal = num.replace(/^[0-9 ] (.[0-9] )?$/,"$1");
var integer= num.replace(/^([0-9] )(.[0-9] )?$/," $1");
var re=/(d )(d{3})/
while(re.test(integer)){
integer =integer.replace(re ,"$1,$2")
}
return symble integer decimal;
} else {
return number;
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn