我想编辑一个文本文档,在每10-12行的末尾有页码(将PDF转换成文本,在页面末尾有页码)。我想删除这些特定的页码整数不在文本中,因为可以有一个页码50,但也可以有一行,其中可以有50作为整数。所以我只想删除页码为整数的行。在
文本文档示例:
1
militant Muslims use scriptures such as the
Genesis story describing the destruction of
Sodom and Gomorrah as justification (from Allah)
for the hatred they vent on all things non-
Muslim and especially on gay men.
2
A Word from the Author
Today, in the 21st Century the majority of Muslims
hold middle
3
Into The Darkness
the driver assured the exhausted travelers who
were dozing fitfully in the rear of the van, they
4
down. It blocked the narrow road.
Ali Azzizi was the other man accompanying
the women.
5
我想删除这些页码从1-5,但如果这些相同的数字出现在任何地方之间的行,它不应该删除。在
我的代码
^{pr2}$
如果python的使用不是强制性的,那么可以使用
grep -v '^[0-9][\s]*' test.txt
。在相关问题 更多 >
编程相关推荐