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

List<T>().Add problem C# -

Javascript natural sort array/object and maintain index association -