How do I make an int "1500000" display as "1 500 000"?

Get help using Construct 2

Post » Sat Dec 13, 2014 6:09 pm

I need something that makes my int display as 1 500 000 in my text object, instead of 1500000.

Anyone that can help?
Posts: 4
Reputation: 185

Post » Sat Dec 13, 2014 7:26 pm

You can use Regex which is a function that scans through text and you can use it to find and replace specific characters

Do a "set text" and paste this in the expression box. Replace "number" with the number or variable you want
Code: Select all
RegexReplace(str(number), "\d{1,3}(?=(\d{3})+(?!\d))", "g", "$& ")

The parameter "$& " tells what to add. If you make it "$&," it will turn 1000 into 1,000. Note that in the line above it has a space after the &, which means it's adding the space character
Posts: 1,039
Reputation: 15,249

Return to How do I....?

Who is online

Users browsing this forum: tdcostas and 11 guests