Skip to main content
added 240 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

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.

Retina, 23 bytes

Lms`^(.+)$(?=.+^\1$)
D`

Try it online! Explanation:

Lms`^(.+)$(?=.+^\1$)

List duplicated lines.

D`

Deduplicate that list.

Retina, 23 22 bytes

Lmsl`(.+)(?=.+^\1$)
D`

Try it online! Explanation:

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.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Retina, 23 bytes

Lms`^(.+)$(?=.+^\1$)
D`

Try it online! Explanation:

Lms`^(.+)$(?=.+^\1$)

List duplicated lines.

D`

Deduplicate that list.