Community
    • Login

    Seatch text file add leading 0 to single digit number

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Richard GeorgeR
      Richard George
      last edited by

      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
      Rich

      1 Reply Last reply Reply Quote 0
      • Jim DaileyJ
        Jim Dailey
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors