Sam Duncan wrote in post #1087818:
> On 12/05/2012 07:31 AM, Alexander G. wrote:
>> 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
>>
> How about;
>
>  > irb
> 1.9.3p125 :001 > s = '$5.99 /LB'
>   => "$5.99 /LB"
> 1.9.3p125 :002 > s.match(/^\$(\d+\.\d+).*$/)[1].to_f
>   => 5.99
>
> You may want to split it into steps and do some error checking, or just
> wrap it in a rescue, depending on where your input comes from and where
> your output is going.
>
> Sam

Sorry didn't work for me.
That's what it returns: $5.99 /LB
still the same

-- 
Posted via http://www.ruby-forum.com/.