The Formatting Function Code For numeric projects. For more information, see.
The Code is as follows:
//--------------------------------------------
// Delete a shard.
//--------------------------------------------
Function removeComma (number ){
Var num = number. replace (new RegExp (",", "g "),"");
If (/^ [-+]? [0-9] + (\. [0-9] + )? $/. Test (num )){
Return num;
} Else {
Return number;
}
}
//--------------------------------------------
// Add a shard.
//--------------------------------------------
Function addKannma (number ){
Var num = number. replace (new RegExp (",", "g "),"");
// Process Positive and Negative Numbers
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;
}
}