Reputation: 315
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
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