任何人都可以帮我匹配来自之间的文字以及第一次出现的主题来自以下一行,
输入
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
输出
From: person@example.com
Date: 01-01-2011
To: friend@example.com
Subject: This is the subject line
我尝试使用以下正则表达式
/(From:.*(?i)Subject:.*?)\n/m
上面的正则表达式选择直到最后一个主题