Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarissaJ/905abeb1baa37fc1ba736484e175fd85 to your computer and use it in GitHub Desktop.
Save MarissaJ/905abeb1baa37fc1ba736484e175fd85 to your computer and use it in GitHub Desktop.
Add Commas Javascript Global Replace function
total=text.sourceText;
function formatNumber(total) {
return total.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')
}
formatNumber(total)
@MarissaJ
Copy link
Author

MarissaJ commented Apr 2, 2020

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment