ruby on rails - How can I check if a value is a number? -


i want check if returned value form text field number i.e.: 12 , 12.5 or 12.75. there simple way check this, if value pulled param?

just regexp it, it's trivial, , not worth thinking beyond that:

v =~ /\a[-+]?[0-9]*\.?[0-9]+\z/ 

(fixed per justin's comment)


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -