请查看以下内容:https://regex101.com/r/xSDG43/1/。 我想删除段落之间的这种“噪音”。由于正在处理的文档中存在违规行为,因此我无法真正避免使用它们。
上面的模式会产生我想要的结果,但是如果在我的代码中实现,则不会。
import re
txt = re.sub(r'/^.{1,16}\n/gm', r'', txt) # no
txt = re.sub(r'^.{1,16}\n', r'', txt, re.M) # no
txt = re.sub(r'^.{1,16}\n', r'', txt) # no
有什么主意吗?