# Library to rurn money into nominal value?

**URL:** <https://www.ruby-forum.com/t/library-to-rurn-money-into-nominal-value/83214>\
**Category:** Ruby\
**Created:** [January 24, 2007, 12:02pm UTC](https://www.ruby-forum.com/t/library-to-rurn-money-into-nominal-value/83214 "2007-01-24T12:02:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![splattael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@splattael](https://www.ruby-forum.com/u/splattael)\
**Post date:** [January 24, 2007, 12:02pm UTC](https://www.ruby-forum.com/t/library-to-rurn-money-into-nominal-value/83214/1 "2007-01-24T12:02:20Z")

</div>

Hi,

I wonder if there is something like $subj so that I don’t reinvent the  
wheel. What I need is something like:

money\_to\_val(‘$12.56’) =\> 12.56  
money\_to\_val(‘$ 12.56’) =\> 12.56  
money\_to\_val(‘$ 12,56’) =\> 12.56  
money\_to\_val(‘US$ 12,56’) =\> 12.56  
money\_to\_val(‘12.56$’) =\> 12.56  
money\_to\_val(‘USD 12.56’) =\> 12.56

maybe even

money\_to\_val(‘12 dollars, 56 cents’) =\> 12.56

Probably what I need to cover 95% of the cases is to remove all the  
non-digits except a delimiter (, or .) I guess. Or not?

Thanks,  
Peter

\_\_  
[http://www.rubyrailways.com](http://www.rubyrailways.com)

---

<div class="post-metadata">

**Author:** ![splattael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@splattael](https://www.ruby-forum.com/u/splattael)\
**Post date:** [January 24, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/library-to-rurn-money-into-nominal-value/83214/2 "2007-01-24T14:06:42Z")

</div>

Peter S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote/schrieb  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Probably what I need to cover 95% of the cases is to remove all the  
> non-digits except a delimiter (, or .) I guess. Or not?

Attention to locales! At least these variants for 1234567.89 exist in  
different countries:  
1 234 567,89  
1.234.567,89  
1,234,567.89  
1 234 567.89  
1’234’567.89  
1,234,567Â·89  
(See [http://de.wikipedia.org/wiki/Dezimaltrennzeichen](http://de.wikipedia.org/wiki/Dezimaltrennzeichen).)

Regards  
Thomas
