From: sto.mar@... Date: 2012-12-05T05:14:11+09:00 Subject: Re: Extract number (float) from string Am 04.12.2012 21:00, schrieb sto.mar@web.de: > Am 04.12.2012 19:31, schrieb Alexander G.: >> Hi Please advice how to extract exact number from string: >> >> $5.99 /LB >> >> I need to get 5.99 as float number >> >> Thank you in advance >> > > Using float for currency is a bad idea. > > [13] pry(main)> 1.11 - 0.12 > => 0.9900000000000001 /\$(?\d+)\.(?\d+)/ =~ "$5.99 /LB" amount_in_cent = 100 * dollars.to_i + cents.to_i # => 599 (see RegExp documentation) --