re = /^Case title: +(?<caseTitle>.*\S) *\n+Client: +(?<client>.*?\S) *\n+Origin: +(?<origin>.*?\S) *\n+Contact: +(?<contact>.*?\S) *\n+DSM: +(?<dsm>.*?) *\n+CSM: +(?<csm>.*?\S) *\n+Assigned To: +(?<assignedTo>.*?\S) *\n+Due Date: +(?<dueDate>.*?\S) *\n+Description: +(?<desc>.*?\S) *$/mi
str = 'Case title: Sample Test case 9
Client: 8688211
Origin: Email
Contact: testing@me.com
DSM: testContact1
CSM: testContact1
Assigned To: testing@me.com
Due Date: 06/28/2023
Description: Sample description 9
Case title: Sample Test case 9
Client: 8688211
Origin: Email
Contact: testing@me.com
DSM: testContact1
CSM: testContact1
Assigned To: testing@me.com
Due Date: 06/28/2023
Description: Sample description 9 '
# 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