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#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

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

openssl - Load PKCS#8 binary key into Ruby -