Sublime Forum

Regex for remove duplicated numbers

#1

Hi to all,

I’m trying to edit a file with duplicate numbers, in the following pattern:

39

39

and I would like to remove the duplicate keeping only one of the numbers.

These numbers start from 1 and go to infinity. Thanks in advance.

To make it clearer, here’s an example of what I want to do:

9

9

00:00:22,997 --> 00:00:26,832
that takes initiative and is proactive about learning.

to this:

9
00:00:22,997 --> 00:00:26,832
that takes initiative and is proactive about learning.

0 Likes

#2

search ^(\d+)\n+\1\n+
replace with $1\n

1 Like

#3

Thank you! Worked perfectly!

I had to modify only Replace, adding a new line, looking like this: \n$1\n

Again, thank you very much!

0 Likes