Question: I need a way to format numbers. I stored some numbers in my DB table, e.g. `12500`, and would like to print them in this format `12 500` (so there is a space every 3 digits). Is there an elegant way to do this?

Answer: 
Activesupport uses this regexp (and no reverse reverse).

```
10000000.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1 ") #=> "10 000 000"

```
Another way:
Here "delimiter is `' '`(space), you can specify `','` for money conversion."

```
number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, "\\1#{delimiter}").reverse

```