Monday, January 24, 2011

Is the string has numeric value?

for check the string has numeric value or not then you can do it by below
s = "123cs"

then call method as below

and the method is as below
 def is_numeric?(s)
    s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true

No comments:

Post a Comment

Contact Me for any help regarding rails/nodejs/php/mysql


Email *

Message *