Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@MarissaJ 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