Seatch text file add leading 0 to single digit number

  • I have a text file that I export form a database program but does not allow a leading 0 on a single digit number so when I sort them it looks like this

    Title Volume
    Book1 1
    Book10 10
    Book2 2

    Ive been manually seach and replace 1 with 01 2 with 02 etc but i was wondering if anyone could tell me a better way to replace all the numbers 1 to 9 with 01 to 09

    thanks in advance

  • You could try something like this (be sure to check Regular expression in the Replace dialog):

    Find what: ([^0-9])([0-9][^0-9])
    Replace with: \10\2

    It finds any character that is NOT in the set [0…9] followed by a character that is, followed by any character that is not. That gets replaced by the first character found, a “0”, and the last 2 characters that were found.

Log in to reply