0

How can I change number without formating and decimal values (like: 125478521478) to string that has spaces every 3 digits (like: 24 148 147), it would have to convert ~100 of those numbers so I'm looking for efficient solution.

  • In a spreadsheet? An uiApp application? Please specify the context....there is a gs method called utilities.formatString that is designed to do such things...see the docs here https://developers.google.com/apps-script/reference/utilities/utilities – Serge insas Jun 19 '14 at 15:35
  • @Sergeinsas I saw that one but I could not manage to create spaces using it, only changed the decimal number count. Might have been error on my part though as I'm quite new to this. – user3733639 Jun 19 '14 at 18:23

1 Answers1

0

This script should help you. You can run this script in a loop for all the numbers. Considering 125478521478 as your number for demonstration. The code shall be as follows -

var yourNumber = "125478521478";
yourNumber  = yourNumber.toString().replace(/,/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, " ");

Hope it helps!

Swanidhi
  • 2,029
  • 1
  • 20
  • 21