re = /^ab.*[zy].*s/
str = 'abrazos
abyes
abys
abysm
abysmal
abysmally
abysms
free
friday
smelly
Write a regular expression to find all words which have the first two characters of "ab", and after that at some point EITHER a "z" or a "y", and then after that at some point an "s". The "s" does not have to be at the end of the word.
So the following words are all examples of words which you should be able to find (although there are many more words which match which are not listed here):'
# Print the match result
str.match(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html