D
D
Dmitry Chesnokov2020-11-06 10:32:38
Regular Expressions
Dmitry Chesnokov, 2020-11-06 10:32:38

NotePad++ How to replace numbers at the beginning of a line?

There is a document with personal accounts of the form:
123; Ivanov Ivan Ivanovich
12; Neivanov Neivan Neivanovich
12345; Still Some Type

It is necessary to bring all personal accounts to the same length:

00123; Ivanov Ivan Ivanovich
00012; Neivanov Neivan Neivanovich
12345; Another Some Type

A very long time ago I did it like this: RegExp Find: ^([0-9]{2, 2})
Replace \0001

in the "Find" field changed {1,1} or {3,3} to find personal account of the required length

But I forgot how it was exactly written.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dollar, 2020-11-06
@d9m0n4ik

Suitable \b(\d{2,2})\b
\d - digit
\b - word boundary
Replace with 000$1
$1 - found substring

G
Grigory Boev, 2020-11-06
@ProgrammerForever

1) ^(.*) by 00000$1
2) ^0+(\d{5}); for $1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question