On Aug 26, 2007, at 3:26 PM, Kenneth McDonald wrote:

> The real problem is:
>
> irb(main):002:0> "12,345".to_i
> => 12
>
> Basically, Ruby converts anything that starts with an int, which is  
> really quite nasty in a case such as the above. I spent a lot of  
> time tracking down that problem.
>
> So, I want an integer conversion function that throws an error if  
> the _entire_ string can't be interpreted as an integer; the Ruby  
> analog to the standard string-to-int conversion function in most  
> other languages.

raise "Bad integer" unless i_str =~ /\A-?\d+\z/

James Edward Gray II