Suppose I have this String:
Speaker 1:
Lorem ipsum
Speaker 1:
This is text
Speaker 1:
Another one
Speaker 2:
Yadda Yadda
Speaker 1:
Text
Speaker 2:
New text
I want to to remove the second and third occurence of Speaker 1: but keep the first and fourth one via regex.
I tried using (Speaker 1:)(.|\n)*((Speaker 1:))(.|\n)*(Speaker 2:) to be able to access the groups but this didn't work out.
How can I access only the repeated lines containing Speaker 1: which are followed by Speaker 2:?