Reputation: 7138
Given the following text in an email body:
DO NOT MODIFY SUBJECT LINE ABOVE. Sending this email signifies my Request to Delay distribution of this Product Change Notification (PCN) to 9001 (Qwest). The rationale for this Request to Delay is provided below:
This is the reason I need to capture.
It can be many many lines long.
And go on for a long time
I'm trying to capture all the text that follows "... is provided below:".
The pattern being passed into BodyRegex is:
.*provided below:(?<1>.*)
The code being executed is:
Regex regex2 = new Regex(BodyRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline);
string note = null;
Match m2 = regex2.Match(body);
if (m2.Success)
{
note = m2.Groups[1].Value;
}
The match is not being found.
What match pattern do I need to use to capture all lines of text following "is provided below:"?
Upvotes: 3
Views: 8082
Reputation: 1350
The section (?...) is look ahead syntax which isn't what you want.
You might want to try a look behind instead:
(?<=provided below:)[.|\n|\W|\w]*
I've had issues with .NET not recognizing end of line characters the way you'd expect it to using .* , hence the or conditions.
Upvotes: 5