Last active
August 24, 2022 02:12
-
-
Save MarissaJ/905abeb1baa37fc1ba736484e175fd85 to your computer and use it in GitHub Desktop.
Add Commas Javascript Global Replace function
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
total=text.sourceText; | |
function formatNumber(total) { | |
return total.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') | |
} | |
formatNumber(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adds a comma in the right spaces for text layers used as numbers in Adobe After Effects. Copy code and paste as an expression on a text layer's Source Text property. Great function to apply when using text layers to generate computational math or getting data from a spreadsheet. Of course if you're doing none of these things you can just type a comma :)