python - 从具有匹配模式的文档中删除某些句子
问题描述
我有文本文档
text = 'This is a follow-up to your previous request #16302 "asdkjc!!!"\n\nHello asd,\n\nSo I\'ve just received the check and a signed letter from the asc acs, .....'
我想This is a follow-up to your previous request #16302 "asdkjc!!!"
从文档中删除。
我试过了 :
re.sub(r'this is a follow-up to your previous request #[0-9] ["](.*?)["]', " ", text)
这无法删除。
解决方案
你可以使用:
re.sub(r'This is a follow-up to your previous request #[0-9]+ ["](.*?)["]', " ", text)
输出:
" \n\nHello asd,\n\nSo I've just received the check and a signed letter from the asc acs, ....."
推荐阅读
- firewall - Fortigate 和 FortiExplorer
- visual-studio - 在我的 Web 窗体上创建一个按钮以打开我的 CrystalReportViewer
- c# - C# 在异步线程中获取 ApplicationName
- jquery - 如何让 jQuery Ajax 调用发布到用 ValidateAntiForgeryToken 装饰的 Action
- swift - 如果 UITextField 被隐藏,则重置 UILabel 左侧的字符
- python - Python中的枕头不会让我打开图像(“超过限制”)
- html - 一个垂直的 div,左右两边都有一个图像模式
- bash - 当talker从启动运行时,master上没有收到消息
- vue.js - VueJs v-if 阻止实时通知
- sql - SQL 数据库 - PK 和 FK