#pattern="[^b]*b[^b]*b[^b]*b[^b]*$" #contains 3 b's, may not be consecutive.
#pattern = ["^c[aouei][a-z]*$"]	#starts with c, followed by one vowel,and any number of letters 
#pattern << "ruby"	#contains "ruby"
#pattern << "s{3}|c{3}" #contains sss or ccc
#pattern = ["^c[aouei][a-z]*$"] #starts with c, a wovel , and any letter any number of times
#pattern << "ruby"  #contains ruby
#pattern << "(ab){2}" #contains 2 ab
#pattern << "b{2}"  #contins 2b
#pattern = "^a[a-z]?$"  #starts with a, 0 or 1 letter after that
#pattern = "(ab|ba)+" # contains one or more ab
#pattern = "^ste(ve|phen|ven)$"  #steve, steven, or stephen
#pattern = ^ste(ve|phe|)n?$#steve, steven, or stephen
#pattern = "^(..)*$"   #even length string
#pattern = "^([^aouei]*[aouei][^aouei]*[aouei][^aouei]*)*$"  #even number of wovels
#| (^[^b]+(b+[^b])*0)
#pattern = ["^c[aouei][a-z]*$"] #starts with c, a wovel , and any letter any number of times
#pattern << "ruby"  #contains ruby
#pattern << "(ab){2}" #contains 2 ab
#pattern << "b{2}"  #contins 2b
#pattern = "^a[a-z]?$"  #starts with a, 0 or 1 letter after that
#pattern = "(ab|ba)+" # contains one or more ab
#pattern = "^ste(ve|phen|ven)$"  #steve, steven, or stephen
#^ste(ve|phe|)n?$#steve, steven, or stephen
# re = Regexp.new("^" + "a" )
#pattern = "^(..)*$"   #even length string
#pattern = "^([^aouei]*[aouei][^aouei]*[aouei][^aouei]*)*$"  #even number of wovels
#pattern = "^(b([^b]+b*)*[^b])$"
pattern = "^(b[a-z]*[^b])$|^([^b][a-z]*b)$"  #starts with b or ends with b, but not both
file="war_peace.txt"
fp = open(file)
cnt = 0
while line =  fp.gets do
    words = line.split(/[<>\/,?!.\s'\-()":;*]/)  #split each line into a words array
    words.each{|word| 
      word.downcase!
      if(word.match(/#{pattern}/))
        print word,"\t"
        cnt += 1
      end
        exit if cnt >  10
    }
end
