Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 什么样的regexp可以用来标识;原始信息;gmail中的前缀?_Python_Regex_Roundup - Fatal编程技术网

Python 什么样的regexp可以用来标识;原始信息;gmail中的前缀?

Python 什么样的regexp可以用来标识;原始信息;gmail中的前缀?,python,regex,roundup,Python,Regex,Roundup,例如,签名可以是: On Tue, Mar 20, 2012 at 2:38 PM, Johnny Walker <johnny.talker@gmail.com> wrote: 2012年3月20日星期二下午2:38,约翰尼·沃克写道: 然后是引用的回复。我确实有一种离散的感觉,虽然这是特定于语言环境的,但这让我成为一个悲伤的程序员 我之所以要求这样做,是因为在通过gmail回复问题时没有正确地去除这些内容。我认为,origmsg\u re是我需要在keep\u quoted\

例如,签名可以是:

On Tue, Mar 20, 2012 at 2:38 PM, Johnny Walker <johnny.talker@gmail.com> wrote:
2012年3月20日星期二下午2:38,约翰尼·沃克写道:
然后是引用的回复。我确实有一种离散的感觉,虽然这是特定于语言环境的,但这让我成为一个悲伤的程序员

我之所以要求这样做,是因为在通过gmail回复问题时没有正确地去除这些内容。我认为,
origmsg\u re
是我需要在
keep\u quoted\u text=no
旁边设置的config.ini变量来解决这个问题

现在它是默认的
origmsg\u re=^[>\s]*-\s?原始消息\s?-$

编辑:现在我使用的是
origmsg\u re=

^在[^上,以下正则表达式将以非常安全的方式匹配Gmail前缀。它确保在…上有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

谢谢,我最终还是用了这个:
origmsg\u re=^On.+写了:$