Skip to content

Instantly share code, notes, and snippets.

@hsnaydd
Created July 7, 2015 09:26
Show Gist options
  • Save hsnaydd/cad765b8f7d88844a6a3 to your computer and use it in GitHub Desktop.
Save hsnaydd/cad765b8f7d88844a6a3 to your computer and use it in GitHub Desktop.
Binler basamaklarını nokta ile ayırma
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