for check the string has numeric value or not then you can do it by below
s = "123cs"
then call method as below
is_numeric?(s)
and the method is as below
def is_numeric?(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
end
s = "123cs"
then call method as below
is_numeric?(s)
and the method is as below
def is_numeric?(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
end
No comments:
Post a Comment