re = /^Name\R(.+)\REmail\R(.+)\RPhone Number\R(.+)\RInquiry or Message\R(?s)(.+)/
str = 'Name
Troy LastName
Email
troytesting3@gmail.com
Phone Number
914 361-9012
Inquiry or Message
message as a test
to process'
# 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