Reputation: 195
I don't want to see if user input is an integer value, I just want to see if there's an integer within the user's input (a string).
I was thinking of using include? or contains but neither worked for me.
Upvotes: 0
Views: 142
Reputation: 211540
Lazy solution:
input = gets.chomp
input[/\d+/]
You can also check with match?
on Ruby 2.6+:
input.match?(/\d+/)
Upvotes: 3