Created
July 7, 2015 09:26
-
-
Save hsnaydd/cad765b8f7d88844a6a3 to your computer and use it in GitHub Desktop.
Binler basamaklarını nokta ile ayırma
This file contains hidden or 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
function doThousands(n) { | |
n = '' + n; | |
if (n.length < 4) return n; | |
var c = n.length % 3; | |
var pre = n.substring(0, c); | |
return pre + (pre.length? ',' : '') + n.substring(c).match(/\d{3}/g).join(','); | |
} | |
function doThousandsRegExp(n) { | |
if (n.length < 4) return n; | |
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment