在gmail中识别“原始邮件”前缀的regexp是什么?

2024-09-28 03:19:04 发布

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

签名示例可以是:

On Tue, Mar 20, 2012 at 2:38 PM, Johnny Walker <johnny.talker@gmail.com> wrote:

接着是引用的回复。我有一个离散的感觉,这是特定的地区,虽然这使我成为一个悲伤的程序员。你知道吗

我要求这样做的原因是roundup在通过gmail回复问题时没有正确地剥离这些内容。我认为origmsg_re是配置.ini我需要在keep_quoted_text = no旁边设置变量来解决这个问题。你知道吗

现在它是默认的origmsg_re = ^[>|\s]*-----\s?Original Message\s?-----$

编辑:现在我使用的是origmsg_re = ^On[^<]+<.+@.+>[ \n]wrote:[\n],它适用于一些gmail客户机,它们会打断过长的行。你知道吗


Tags: recom示例ongmailmaratwalker
1条回答
网友
1楼 · 发布于 2024-09-28 03:19:04

下面的正则表达式将以相当安全的方式匹配gmails前缀。它确保有3个逗号和升文本。。。写道

On([^,]+,){3}.*?wrote:

如果正则表达式应该以不区分大小写的方式匹配,那么不要忘记添加修饰符。你知道吗

if re.search("On([^,]+,){3}.*?wrote:", subject, re.IGNORECASE):
    # Successful match
else:
    # Match attempt failed

谨致问候,巴克利

Match the characters “On” literally «On»
Match the regular expression below and capture its match into backreference number 1 «([^,]+,){3}»
   Exactly 3 times «{3}»
   Note: You repeated the capturing group itself.  The group will capture only the last iteration.  Put a capturing group around the repeated group to capture all iterations. «{3}»
   Match any character that is NOT a “,” «[^,]+»
      Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
   Match the character “,” literally «,»
Match any single character that is not a line break character «.*?»
   Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
Match the characters “wrote:” literally «wrote:»

Created with RegexBuddy

相关问题 更多 >

    热门问题