Hmm, nice. My friend gave me something I never saw before:
function addPoint(numTxt) {
numTxt = String(numTxt);
regEx = /^(.*\s)?([+-]?\d+)(\d{3}\b)/;
return numTxt == (numTxt = numTxt.replace(regEx, “$1$2,$3”)) ? numTxt : addPoint(numTxt);
}
This worked fine to do what I wanted, but I almost died when I saw that.
It works like this, in a source text:
function addPoint(numTxt) {
numTxt = String(numTxt);
regEx = /^(.*\s)?([+-]?\d+)(\d{3}\b)/;
return numTxt == (numTxt = numTxt.replace(regEx, “$1$2,$3”)) ? numTxt : addPoint(numTxt);
}
addPoint (56448646455646848668)
You are done!