Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addDashLine = function (val) {
- var comma = '_'
- var num = val.toString().replace(/,/g, '');
- if (num.length != 0 && parseInt(num, 10)) {
- var regex = new RegExp('([0-9]{4})(-?[0-9]+)');
- while (regex.test(num)) {
- num = num.replace(regex, '$1' + comma + '$2');
- }
- }
- return num;
- };
- alert(addDashLine(123456789))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement