re = /.*?-.*?-.*?-\s+(.*)/
str = '005 - 0000 - 2310 - Storage - Summer
007 - 0000 - 1610 - Legal - Criminal Law
007 - 0000 - 8921 - Legal - Civil - Zoning
002 - 0000 - 2410 - Planning
123 - 0000 - 2510 - Finance/Corporate
008 - 0000 - 2520 - Legal - Technical Patents
321 - 0000 - 2610 - Clients & Storage'
# 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