删除所有不以字母或标点符号开头的行

Delete all lines that do NOT start with letters or punctuation marks

我有一个非常长的文本文件,格式如下:

1
00:00:00,000 --> 00:00:16,700
to use 2 languages.

2
00:00:16,700 --> 00:00:19,600
I was saying that we are going to use 2 languages

3
00:00:19,600 --> 00:00:24,700
...I myself will continue to speak because of time

现在我想删除除文本以外的所有内容,所以结果应该是:

to use 2 languages.
I was saying that we are going to use 2 languages
...I myself will continue to speak because of time

正确的正则表达式命令是什么?删除所有包含数字的行的命令也可以使用。我正在使用 Sublime Text 或 regex101.com

/(?:^|\n)\d+\n[\d\:\,\s\->]+/g

这似乎是一个不错的正则表达式。用 \n 代替它,你只剩下单词。

Demo.

这两个都需要多行不区分大小写模式。
它们内联在正则表达式中,但可以指定为查找选项之一。

替换为空字符串。

对于标点符号,这使用属性:

 # (?im)(?:^[^\p{punct}a-z].*\s*)+

 (?im)
 (?:
      ^ 
      [^\p{punct}a-z] 
      .* 
      \s* 
 )+

这个使用 POSIX:

 # (?im)(?:^[^[:punct:]a-z].*\s*)+

 (?im)
 (?:
      ^ 
      [^[:punct:]a-z] 
      .* 
      \s* 
 )+