Can anyone help me to match the text between From and first occurrence of Subject from the following set of lines,
Input
Random Line 1
Random Line 2
From: person@example.com
Date: 01-01-2011
To: friend@example.com
Subject: This is the subject line
Random Line 3
Random Line 4
Subject: This is subject
This is the end
Output
From: person@example.com
Date: 01-01-2011
To: friend@example.com
Subject: This is the subject line
I tried with the following regular expression,
/(From:.*(?i)Subject:.*?)\n/m
The above regexp selects till the last Subject