我有以下作为我的输入,
输入
Random Line 1
Random Line 2
From: person1@example.com
Date: 01-01-2011
To: friend@example.com
Subject: One
Random Line 3
Random Line 4
From: person2@example.com
Subject: Two
Random Line 5
From: person3@example.com
Subject: Three
This is the end
以下是我预期的匹配文本,
预期产出
From: person2@example.com
Subject: Two
注意:From: person2@example.com和Subject: Two之间可能有零行或多行
我尝试使用正则表达式,
/(From.*?Subject:\s*Two)/m
上面的正则表达式匹配第一个From。谁能帮我匹配预期的输出?提前致谢。