从记事本中的字幕文件中删除空行和时间戳

时间:2018-11-30 12:34:46

标签: timestamp notepad++ subtitle

我想从记事本++字幕文件中删除空行和时间戳

我知道已经问过这个问题,答案是以下代码: ^ [\ d \ s \ n]。* \ n

但是,如果文本开头是数字,则该行也会被删除。

例如,在以下几行:

1-我们已经看到了更好的组织代码的方法

2-我们已经看到了处理文件的方法,

Match

1 个答案:

答案 0 :(得分:1)

  • Ctrl + H
  • 查找内容:^\R?(\d+)\R\d\d:\d\d.+\R
  • 替换为:$1 -
  • 检查环绕
  • 检查正则表达式
  • 取消检查. matches newline
  • 全部替换

说明:

^           # beginning of line
\R?         # any kind of linebreak, optional
(\d+)       # group 1, 1 or more digits
\R          # any kind of linebreak
\d\d:\d\d   # 2 digit, colon, 2digit
.+          # 1 ormore any character but newline
\R          # any kind of linebreak

替换:

$1  # content of group 1, digits
 -  # space, dash, space

给定示例的结果

1 - <v Instructor>We can go back now</v>
2 - to our web server checklist.
3 - 1- We've already seen better ways to organise our code
4 - into reusable pieces with modules,
5 - 2- we've seen ways to deal with files,
6 - both synchronous and asynchronous,
7 - and buffers,
8 - both the built-in Node one
9 - and the ES6 buffers,
10 - and we've seen a way to deal with work