I have a regexp that detects a series of digits, or a series of characters including space.
I need to do one of two actions, depending on whether the result is a "number" or not. The $1 result is always a string though, even if it's just a string of digits.
$1.to_i returns 0 if $1 contains something other than digits, but it also returns 0 if the string is '0'.
Is there another way, other than converting it to an array and checking each character?
I need to do one of two actions, depending on whether the result is a "number" or not. The $1 result is always a string though, even if it's just a string of digits.
$1.to_i returns 0 if $1 contains something other than digits, but it also returns 0 if the string is '0'.
Is there another way, other than converting it to an array and checking each character?