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:"?
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.
Use this regex with single line option
^.*?provided below:(.*?)$
works here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With