# "10,000" -\> 10000

**URL:** <https://www.ruby-forum.com/t/10-000-10000/170193>\
**Category:** Ruby\
**Created:** [June 13, 2009, 3:40pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193 "2009-06-13T15:40:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 13, 2009, 3:40pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193/1 "2009-06-13T15:40:43Z")

</div>

Rubies:

Besides .gsub(’,’, ‘’).to\_i, what’s a good way to un-delimit a big  
number?

Ideally, it should be the reverse of Rails’s number\_with\_delimiter…

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 13, 2009, 4:45pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193/2 "2009-06-13T16:45:08Z")

</div>

On Sat, Jun 13, 2009 at 3:40 PM, Phlip[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Rubies:
> 
> Besides .gsub(‘,’, ‘’).to\_i, what’s a good way to un-delimit a big number?
> 
> Ideally, it should be the reverse of Rails’s number\_with\_delimiter…
> 
> –  
> Phlip

I would be quite happy with gsub, but if you want another shot on it  
you might do  
scan(/\d/).join  
or  
scan( /[+\d-]).join

HTH  
Robert

–  
Toutes les grandes personnes ont d’abord été des enfants, mais peu  
d’entre elles s’en souviennent.

All adults have been children first, but not many remember.

[Antoine de Saint-Exupéry]

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 13, 2009, 7:09pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193/3 "2009-06-13T19:09:52Z")

</div>

Hi,

Am Samstag, 13. Jun 2009, 22:40:09 +0900 schrieb Phlip:

> Besides .gsub(’,’, ‘’).to\_i, what’s a good way to un-delimit a big number?

str.delete “,”

If you like to check the syntax:

str.gsub /,(\d\d\d)\b/, “\1”

Bertram

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 14, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193/4 "2009-06-14T23:47:45Z")

</div>

Robert D. wrote:

> I would be quite happy with gsub, but if you want another shot on it  
> you might do  
> scan(/\d/).join  
> or  
> scan( /[+\d-]).join

Txbut - imagine if number\_with\_delimiter magically imbued your string  
with  
locale awareness (like the C++ imbue do).

We got anything high-level like that? Some cultures reverse the roles of  
commas  
& dots. (I don’t rly need locales myself; I’m just annoying the envelop  
here…)

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 15, 2009, 2:05am UTC](https://www.ruby-forum.com/t/10-000-10000/170193/5 "2009-06-15T02:05:15Z")

</div>

Phlip wrote:

> Robert D. wrote:
> 
> We got anything high-level like that? Some cultures reverse the roles of  
> commas  
> & dots. (I don’t rly need locales myself; I’m just annoying the envelop  
> here…)

I think the real issue here is getting those cultures to use commas and  
dots correctly.

/kidding

James

---

<div class="post-metadata">

**Author:** ![Phlip](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed8c4c/32.png) [@Phlip](https://www.ruby-forum.com/u/Phlip)\
**Post date:** [June 14, 2009, 11:47pm UTC](https://www.ruby-forum.com/t/10-000-10000/170193/6 "2009-06-14T23:47:44Z")

</div>

Bertram S. wrote:

> str.delete “,”

The near-term winnah! I didn’t know .delete() would do them all…

> If you like to check the syntax:

It’s for Cucumber tables, so if it’s in-house, I don’t need to annoy my  
clients.  
If I could get them to author the tables anyway…
