I was importing string values and needed to check that it was a positive number
Heres a simple regex to check this. This example will only work for positive integers.
"123abc" !~ /\D/ # => false
"123" !~ /\D/ # => true
Related External Links:
I was importing string values and needed to check that it was a positive number
Heres a simple regex to check this. This example will only work for positive integers.
"123abc" !~ /\D/ # => false
"123" !~ /\D/ # => true
Related External Links:
Article Topic:Software Development - Ruby / Rails
Date:March 21, 2016
Want me to help develop your next Ruby-on-Rails project or application?
Contact Me