Community
    • Login

    Seatch text file add leading 0 to single digit number

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.4k Views 2 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors