Hello, all
I have one string in my controller but i need to knwon how i verify if
it is numerical
Thanks…
Hello, all
I have one string in my controller but i need to knwon how i verify if
it is numerical
Thanks…
Regexp to the rescue:
if s =~ /[0-9]+/
end
And you can go from there, something like:
if s =~ /-?[0-9]+.[0-9]+/
end
and further:
if s =~ /-?[0-9]+(.[0-9]+)/
end
And so on. Hope I got regexp right.
There might be pre-fab methods that do this, but I’m not sure off the
top of my head.
String numecal validate! wrote:
Hello, all
I have one string in my controller but i need to knwon how i verify if
it is numericalThanks…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs