用于从电子邮件主题中删除“FWD”、“RE”等的Regex/代码

2024-06-01 06:41:50 发布

您现在位置:Python中文网/ 问答频道 /正文

给定一个电子邮件主题行,我想清理它,摆脱“Re:”、“Fwd”和其他垃圾。因此,例如,“[转发]回复:杰克和吉尔的婚礼”应该变成“杰克和吉尔的婚礼”。

一定有人以前做过,所以我希望你能给我指一指经过测试的regex或代码。

这里有一些需要清理的示例,可以在this page上找到。该页面上的regex运行得相当好,但并不完全正确。

Fwd : Re : Re: Many
Re : Re: Many
Re  : : Re: Many
Re:: Many
Re; Many
: noah - should not match anything
RE--
RE: : Presidential Ballots for Florida
[RE: (no subject)]
Request - should not match anything
this is the subject (fwd)
Re: [Fwd: ] Blonde Joke
Re: [Fwd: [Fwd: FW: Policy]]
Re: Fwd: [Fwd: FW: "Drink Plenty of Water"]
FW: FW: (fwd) FW:  Warning from XYZ...
FW: (Fwd) (Fwd) 
Fwd: [Fwd: [Fwd: Big, Bad Surf Moving]]
FW: [Fwd: Fw: drawing by a school age child in PA (fwd)]
Re: Fwd

Tags: re电子邮件matchnotthismanyregexsubject