This regex should do the trick:
/(\d+\r\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}\r)([^\r]+)\r([^\r]+)(\r|$)/g
To make this work with more lines (has to be a set number) then just add more ([^\r]+)\r
's. (Remember to also add $
's to the match replace as so (with 3 lines): '$1$2 $3 $4\r'
).
Usage
mystring = mystring.replace(/(\d+\r\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3}\r)([^\r]+)\r([^\r]+)(\r|$)/g, '$1$2 $3\r');
Limitations
- If there is more than 2 lines of text this won't work.
Example 1
Works fine!
Input:
18
00:00:50,040 --> 00:00:51,890
All the women gather
at the hair salon,
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters
and they dye their hair orange.
Output:
18
00:00:50,040 --> 00:00:51,890
All the women gather at the hair salon,
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters and they dye their hair orange
Example 2
Doesn't work; more than 2 lines
Input:
18
00:00:50,040 --> 00:00:51,890
All the women gather
at the hair salon,
and they just talk
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters
and they dye their hair orange.
Except for Maria who dyes it pink.
Output:
18
00:00:50,040 --> 00:00:51,890
All the women gather at the hair salon,
and they just talk
19
00:00:52,080 --> 00:00:56,210
all the mothers and daughters and they dye their hair orange.
Except for Maria who dyes it pink.