Skip to content

Instantly share code, notes, and snippets.

@cange
Created July 29, 2009 15:28
Show Gist options
  • Save cange/158217 to your computer and use it in GitHub Desktop.
Save cange/158217 to your computer and use it in GitHub Desktop.
/**
* Returns a string in which all 3 after a number exceeded a point is set.
* @param {String,Number}
* @example pointSeperatorHelper(1234567) // -> "1.234.567"
* @return {String}
*/
function pointSeperatorHelper (value) {
value = String(value);
var regExp = new RegExp('(-?[0-9]+)([0-9]{3})');
while(regExp.test(value)) {
value = value.replace(regExp, '$1.$2');
}
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment