0

I have a dual .srt file that looks like this:

1
00:07:14,120 --> 00:07:16,953
[French line]
[Russian line]

2
00:07:16,960 --> 00:07:19,952
[French line]
[Russian line]

3
00:07:21,240 --> 00:07:24,835
[French line]
[Russian line]

I would like to delete all the Russian lines (plus the corresponding CRLF's). Which means lines 4, 9, 14, 19, 24, 29, and so on. It's every 5 lines, starting at line 4.

I guess Notepad++'s "Find in files" should be able to do it with the right RegEx (but I'm open to any solution). Could you please help me with that? Thank you.

  • 1
    is *[Russian line]* a fix text? – Jens Sep 26 '22 at 13:38
  • Please include your current regex (how far you got), it's helpful for others to understand the context/data you're processing. – bobble bubble Sep 26 '22 at 13:55
  • @bobblebubble 's answer solved it beautifully. Plus the regex101 site seems really useful. Many thanks for that! Problem solved. – Jose Hidalgo Sep 26 '22 at 15:01
  • @JoseHidalgo Welcome! I think you could further use [`(?>\R?.+){3}\K\R.+`](https://regex101.com/r/Gq8tS6/1) which can be slightly more efficient, I added it to my answer. Glad it helped. – bobble bubble Sep 26 '22 at 15:30
  • 1
    Does this answer your question? [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – AdrianHHH Sep 26 '22 at 16:50

1 Answers1

3

To target every nth line in non empty line sequences:

(?:(?:\R|\A).+){3}\K\R.+

See this demo at regex101 (explanation on right side)

Click on "replace all" and replace with empty.
Make sure to uncheck [ ] dot matches newline in the replace dialogue.
A bit more efficient alternative with atomic group: (?>\R?.+){3}\K\R.+

bobble bubble
  • 16,888
  • 3
  • 27
  • 46