re = /.*\/(JANUARY|SEPTEMBER|NOVEMBER)\/.*/m
str = 'foo/bar/JANUARY/baz
foo/bar/FEBRUARY/baz
foo/bar/MARCH/baz
foo/bar/APRIL/baz
foo/bar/MAY/baz
foo/bar/JUNE/baz
foo/bar/JULY/baz
foo/bar/AUGUST/baz
foo/bar/SEPTEMBER/baz
foo/bar/OCTOBER/baz
foo/bar/NOVEMBER/baz
foo/bar/DECEMBER/baz
'
# Print the match result
str.scan(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