if /([\-\+]?\d+)(\+|\-)([\-\+]?\d+)/ =~ gets then a = $1.to_i b = $3.to_i if $2 == "+" then puts a - b elsif $2 == "-" then puts a + b end end