notepad++srt

Problem with SRT file (index and empty line)


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?


Solution

  • Assumming //empty line don't exist as literal


    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