1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Optional: ?

By

Top Related Searches
  • chomp
  • g string
  • bea
  • beast
  • ruby
  • lt
  • 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

    ©2014 About.com. All rights reserved.