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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -