Page 1 of 1

Find in files: zero pad line numbers

Posted: Thu May 10, 2007 9:54 pm
by tomlamson
I often use find in files and then save the results to a text file and sort on a column number. I want to keep the file name and line number so that I can always resort to get the original order or to manually search the original file. This would be easier if the file number was left padded with zeroes. e.g. if a file has 100 to 999 lines then give a 3 digit line number e.g. (003) (029) (487). Loved TextPad for many years now! Thanks for a great product!

Posted: Thu May 10, 2007 10:36 pm
by ben_josephs
You can fix them in two steps:
Find what: \<([0-9])\>
Replace with: 00\1

[X] Regular expression
Find what: \<([0-9]{2})\>
Replace with: 0\1

[X] Regular expression
These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax