From: Brian Candler Date: 2012-07-13T04:46:22+09:00 Subject: Re: how to check string is numeric or not Aleksey Zapparov wrote in post #1068416: > On Thu, 12 Jul 2012 19:16:08 +0900 > Lucky Nl wrote: > >> check these > def is_numeric(o) > true if Integer(o) rescue false > end This may not be exactly what is wanted: >> Integer("0x123") => 291 If you just want to allow digits and nothing else, use a regexp: /\A\d+\z/ =~ o Also, note that "is_numeric" isn't an ideal name, because Numeric includes Float. >> Float.ancestors => [Float, Precision, Numeric, Comparable, Object, Kernel] -- Posted via http://www.ruby-forum.com/.