Remove duplicate using regex jquery -


i've below text in file.

10 - black 10 - black 10 - black 10 - black 10 - black 20 - grey/black 20 - grey/black 20 - grey/black 20 - grey/black 20 - grey/black 30 - blue 30 - blue 30 - blue 30 - blue 30 - blue 40 - brown/red 40 - brown/red 40 - brown/red 40 - brown/red 40 - brown/red 

here want replace following duplicates, remain letter below is.

in simple want output below.

10 - black     20 - grey/black     30 - blue     40 - brown/red 

here's regex code: (\b[^\n,]+)\n(?=.*\b\1\b) regex101: https://regex101.com/r/wf0ag1/1

edit 1

try regex:

([^\n].*)\n(?:\1(?:\n|$))* 

and substitution:

$1\n\n\n 

demo


Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -