# If the pattern is found, =~ returns its starting position, or nil. line = "this is a Perl" if line =~ /Perl|Python/ puts "Scripting language mentioned: #{line}" end