Bertram Scharpf wrote: > Hi, > > Am Montag, 04. Jun 2007, 22:46:45 +0900 schrieb Stefan Rusterholz: >> w wg wrote: >> > How to check if a string is a integer ? >> >> Also you can use a regex, e.g. str =~ /\A[+-]?\d+\z/ > > In many cases it's useful to test for hex representations as > well. Something like: In those cases I'd even more use Integer(). It accepts about all representations of Integers ruby itself understands. It is probably much faster than a case/when, you also will have the value converted to an integer afterwards, which you most probably want anyway. Regards Stefan -- Posted via http://www.ruby-forum.com/.