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

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -