1

How can I change the following .srt file to look like the one at the end of the post?:

1

1

00:00:01,270  -->  00:00:04,520
<v Narrator>Now before diving into some NodeJS code,</v>
2

2

00:00:04,520  -->  00:00:06,700
let's do a high level overview

I want to change it into this (not duplicate index and remove empty line):

1
00:00:01,270  -->  00:00:04,520
<v Narrator>Now before diving into some NodeJS code,</v>

2
00:00:04,520  -->  00:00:06,700
let's do a high level overview

I think I can use Notepad++ but how?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
hoangtd
  • 198
  • 2
  • 9
  • 3
    Is there literally "//empty line" written in that line or is there jut an empty line (ie with no content) And are there multiple consecutive empty lines, or is there just a single one? – derpirscher Sep 04 '21 at 13:41
  • //empty line: just a single one and no content. – hoangtd Sep 04 '21 at 14:33

1 Answers1

1

Assumming //empty line don't exist as literal


  • Ctrl+H
  • Find what: \R?\d+\R+(\d+\R)\R*(.+\R.+(\R?))
  • Replace with: $1$2$3
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

\R?         # any kind of linebreak, optional
\d+         # 1 or more digits
\R+         # any kind of linebreak
(           # group 1
    \d+         # 1 or more digits
    \R          # any kind of linebreak
)           # end group
\R*         # any kind of linebreak
(           # group 2
    .+          # 1 or more any character but newline
    \R          # any kind of linebreak
    .+          # 1 or more any character but newline
    (\R?)       # group 3, any kind of linebreak, optional
)           # end group

Replacement:

$1          # content of group 1, the digits
$2          # content of group 2, the text
$3          # content of group 3, optional linebreak

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Toto
  • 89,455
  • 62
  • 89
  • 125