Created
July 29, 2009 15:28
-
-
Save cange/158217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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