$string = "Apple
Foo
Banana
...
Banana
Foo
Other text
...
Apple";
I have text where single rows are duplicated after a row "...".
The rows before and after that can be anything ("Foo"), but also be a duplicate (without "..." like "Apple").
The "..."-row can appear multiple times without a duplicate row after it.
I only want to remove duplicated rows which have a "..." row inbetween.
In other words: Remove the line after "..." if it's the same as above "..."
How can I match
Banana
...
Banana
to remove the duplicated row:
Banana
so the result is
$string = "Apple
Foo
Banana
...
Foo
Other text
...
Apple";
Cheers!