【发布时间】:2021-12-23 16:43:33
【问题描述】:
我有一个字符串:
string="(2021-07-02 01:00:00 AM BST)
---
syl.hs has joined the conversation
(2021-07-02 01:00:23 AM BST)
---
e.wang
Good Morning
How're you?
(2021-07-02 01:05:11 AM BST)
---
wk.wang
Hi, I'm Good.
(2021-07-02 01:08:01 AM BST)
---
perter.derrek
we got the update on work.
It will get complete by next week.
(2021-07-15 08:59:41 PM BST)
---
ad.ft has left the conversation
---
* * *"
我只想提取对话文本(名称和时间戳之间的文本)预期输出为:
cmets=['早上好,你好吗?','嗨,我很好。','我们得到了 工作更新。它将在下周完成。']
我试过的是:
cmets=re.findall(r'---\s*\n(.(?:\n(?!(?:(\s\d{4}-\d {2}-\d{2}\s\d{2}:\d{2}:\d{2}\s*[AP]M\s+GMT\s*)\w+\s*\n )?---).))',string)
【问题讨论】:
标签: python-3.x regex string