给定电子邮件正文中的以下文本:
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
我正在 try catch “...在下面提供:”之后的所有文本。
传递给 BodyRegex 的模式是:
.*provided below:(?<1>.*)
正在执行的代码是:
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;
}
未找到匹配项。
我需要使用什么匹配模式来捕获“is provided below:”之后的所有文本行?
最佳答案
(?...) 部分是前瞻语法,这不是您想要的。
您可能想试试看后面:
(?<=provided below:)[.|\n|\W|\w]*
我遇到过 .NET 无法按照您期望的方式使用 .* 识别行尾字符的问题,因此出现 or 条件。
关于c# - 正则表达式 - 查找匹配后的所有行 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12628146/