Retina, 2323 22 bytes
Lms`^Lmsl`(.+)$(?=.+^\1$)
D`
Try it online!Try it online! Explanation:
Lms`^Lmsl`(.+)$(?=.+^\1$)
List duplicated lines. The m
modifier allows the ^
and $
to match the start and end of a line in the lookahead. The s
modifier allows us to look ahead past newlines using just .+
. The l
modifier automatically anchors the match to whole lines. I can't use the p
flag though as the match could be more than one line at once, however the next stage will deal with that.
D`
Deduplicate that list.