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: class String def as_uint case self when /\A0x[0-9a-f]+\z/i then hex when /\A0b[0-1]+\z/ then bin when /\A0[0-7]+\z/ then oct when /\A(?:0|[1-9]\d*)\z/ then to_i end end end There should be a combination of Kernel#eval and $SAFE, too. Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de