re = /\bCHECKOUT[a-zA-Z_(\/ ):]+\w+:\w+\s(?:[AP]M|[ap]m)\s-\s\w+:\w+\s(?:[AP]M|[ap]m)(?!.*\bDRY GOODS\b).*/m
str = 'CHECKOUT Senior Guest Services Manager FRONTENDMGR: 07:00 AM - 08:30 AM SGSM_BOOKKEEPING: 08:30 AM - 01:00 PM FRONTENDMGR: 01:00 PM - 04:00 PM
CHECKOUT Guest Services Manager BOOKKEEPER: 09:00 AM - 01:00 PM DRY GOODS Receiving Clerk RECEIVE: 04:30 AM - 09:00 AM
DRY GOODS Receiving Clerk RECEIVE: 04:30 AM - 09:00 AM CHECKOUT Guest Services Manager BOOKKEEPER: 09:00 AM - 01:00 PM'
# 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