What is the easiest way to find out in Rails 3 whether a string str contains a positive float number or not ? (str is not an attribute in an active-record model)
It should work like this:
str = "123" => true
str = "123.456" => true
str = "0" => true
str = "" => false
str = "abcd" => false
str = "-123" => false
Here’s one idea:
However, since you already seem to have a pretty good idea of what a nonnegative float number looks like, you could also match it against a
Regexp: