The preceding element is optional. Either zero or one of the element may appear in the match text.
#!/usr/bin/env ruby
# Read a <a href="/od/glossary/g/string.htm">string</a> from the keyboard
# Print "success" if the string contains
# either the word "best" or "beast".
word = gets.chomp
if word =~ /bea?st/
puts "success"
end

