makaroN
makaroN

Reputation: 315

Adding numbers to specific lines in notepad++

i want to add number 0 to begining of all string that are 13 characters long.

For example, i have texh file:

f8gh7rt6h4k33p
jk3le1oi0eee9
h0iec40a0jki1
sdf984lk12otra
...

And i want to edit this text file like this:

f8gh7rt6h4k33p
0jk3le1oi0eee9
0h0iec40a0jki1
sdf984lk12otra
...

With this regex i can find all strings that are 13 characters long ([a-zA-Z0-9]{13,13}) but i dont know how to add 0 to begining of the string to these lines.

Upvotes: 1

Views: 294

Answers (2)

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89547

using a lookahead (that means "followed with" and that doesn't consume characters):

\b(?=\w{13}\b)

replacement: 0

or using a capture group and a reference to this capture group in the replacement string:

\b(\w{13})\b

replacement: 0\1

Upvotes: 2

Toto
Toto

Reputation: 91385

  • Ctrl+H
  • Find what: ^(.{13})$
  • Replace with: 0$1
  • Replace all

Upvotes: 2

Related Questions