regex - 如何在 vi 中删除与正则表达式匹配的行?

标签 regex vi

我有一个大文本文件,其中包含以下标题,我正试图将其删除。例如:

1 Nephi 2:13
 13 Neither did they believe that Jerusalem, that great city,
could be destroyed according to the words of the prophets. And
they were like unto the Jews who were at Jerusalem, who sought to
take away the life of my father.
1 Nephi 2:14
 14 And it came to pass that my father did speak unto them in the
valley of Lemuel, with power, being filled with the Spirit, until
their frames did shake before him. And he did confound them,
that they durst not utter against him; wherefore, they did as he
commanded them.
1 Nephi 2:15
 15 And my father dwelt in a tent.
1 Nephi 2:16

我试图删除包含“1 Nephi 2:16”的整行,所以我在 vi 中寻找一个正则表达式来匹配包含书籍和诗句引用的整行。

下面是它需要匹配的示例书和诗句组合列表

1 Nephi 2:16
Mormon 3:7
Alma 32:27
Words of Mormon 1:3

最佳答案

重复 chaos 的答案:如果你能确定任何以冒号分隔的两个数字结尾的行都是标题:

:g/.* [0-9]\+:[0-9]\+$/d

关于regex - 如何在 vi 中删除与正则表达式匹配的行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6751708/

相关文章:

vim:注释/取消注释文件中包含字符串的所有行

javascript - PHP 或 Javascript - 查找特定字符串

linux - 如何在连续的行中为我的 vi 编辑器添加前缀?

Javascript正则表达式匹配k后面不跟数字0

javascript - 使用正则表达式验证自定义表达式

python - LINUX 行尾

linux - 如何在 vi 编辑器中将 Notepad++ 中的代码复制到新文件中?

xml - 正则表达式 : count consecutive occurrence xquery

python - 在 python 中评论正则表达式