Regex 删除所有不以字母或标点符号开头的行
我有一个很长的文本文件,格式如下:Regex 删除所有不以字母或标点符号开头的行,regex,replace,sublimetext3,Regex,Replace,Sublimetext3,我有一个很长的文本文件,格式如下: 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 现在我
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
正确的regex命令是什么?另外,删除包含数字的所有行的命令也可以使用。我正在使用Sublime文本或regex101.com
/(?:^|\n)\d+\n[\d\:\,\s\->]+/g
这似乎是一个很好的正则表达式。用\n
替换它,只剩下单词
.这两种模式都需要多行和不区分大小写的模式。它们在正则表达式中以行形式排列,但可以指定为查找选项之一 替换为空字符串 对于标点符号,它使用以下属性:
# (?im)(?:^[^\p{punct}a-z].*\s*)+
(?im)
(?:
^
[^\p{punct}a-z]
.*
\s*
)+
这一个使用POSIX:
# (?im)(?:^[^[:punct:]a-z].*\s*)+
(?im)
(?:
^
[^[:punct:]a-z]
.*
\s*
)+
是的,这也足以解决问题!