Skip to main content
Inspiring
June 10, 2014
Answered

Format long numbers with commas

  • June 10, 2014
  • 2 replies
  • 2435 views

Hi

I have a table with a lot of 4-digit+ numbers

I would like to add commas to them in the correct places, E.G:

     2000  should be  2,000

     23783  should be  23,783

and so on.

Is there a built in method to do this?

If not, what is the best way to accomplish this?

Thanks,

Davey

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

Use find...replace with Grep:

find what: (\d+)(\d{3})

change to: $1,$2

and repeat it till each multinumber (7+) is matched

Jarek

2 replies

Inspiring
June 18, 2014

Hi, try this

grep {findWhat:"(\\d)(\\d\\d\\d)\\b"} {changeTo:"$1,$2"}

repeat n times

Jump_Over
Legend
June 10, 2014

23783  should be  23,783

What about 2,3783? It never happends?

Jarek

myDaveyAuthor
Inspiring
June 10, 2014

Hi Jarek

Thanks for replying

What about 2,3783? It never happends?

I am not sure what you mean... at least not where I am from!

Its always only 3 digits per comma

3,000

30,000

300,000

3,000,000

Obi-wan Kenobi
Legend
June 10, 2014

Hi,

Adaptation of Peter Spier's solution in another post:

Search:  (\d)(?=\d{3}\>)

Replace by: $0,

To make it cool, using Multi-Find/Change, save the regex and place 10 times in a MFC set. So, with 1 click, you treat all until:

999,999,999,999,999,999,999,999,999,999