Josue
Josue

Reputation: 43

How to delete duplicate numbers in notepad ++?

I've been trying to do use the ^(.*?)$\s+?^(?=.*^\1$) but it doesnt work.

I have this scenario:

9993990487 - 9993990487
9993990553 - 9993990553
9993990554 - 9993990559
9993990570 - 9993990570
9993990593 - 9993990596
9993990594 - 9993990594

And I would want to delete those that are "duplicate" and spect the following:

9993990487
9993990553
9993990554 - 9993990559
9993990570
9993990593 - 9993990596
9993990594

I would really appreciate some help since its 20k+ numbers I have to filter. Or maybe another program, but it's the only one I have available in this PC.

Thanks,

Josue

Upvotes: 2

Views: 66

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626929

You may use

^(\d+)\h+-\h+\1$

Replace with $1.

See the regex demo.

Details

  • ^ - start of a line
  • (\d+) - Group 1: one or more digits
  • \h+-\h+ - a - char enclosed with 1+ horizontal whitespaces
  • \1 - an inline backreference to Group 1 value
  • $ - end of a line.

The replacement is a $1 placeholder that replaces the match with the Group 1 value.

Demo and settings:

enter image description here

Upvotes: 2

Related Questions