fionpo
fionpo

Reputation: 141

Regex keep unique lines

Given this string:


abc quantity
abc quantity

abc quantity
abc quantity
abc quantity    id
abc quantity
abc quantity


I am looking to keep only the unique lines, as in:

abc quantity
abc quantity    id

So far, I have (?s)^(.*)(\r?\n\1)+$ and replacing with $1 as in this demo This is not quiet producing the desired results Any help is appreciated

Upvotes: 0

Views: 155

Answers (1)

Aleks
Aleks

Reputation: 984

My advice is just split the string at \n(new line) and push it to set.

Upvotes: 1

Related Questions