Ruby "=~" matching operator

"=~" is a matching operator with respect to regular expressions; it returns the position in a string where a match was found, or nil if the pattern did not match.

#!/usr/local/bin/ruby
# "=~" is a matching operator with respect to regular
# expressions; it returns the position in a string where a
# match was found, or nil if the pattern did not match.

pat = /[0-9]/

input = "2"
input1 = "a"
regx = Regexp.new(pat)

if input =~ regx
# if input =~ input1
   puts "yes"
else
   puts "no"
end