Find and replace first digit with notepad++

6,677

Is there a way to just change the first number?

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to [0-9]([0-9])([0-9])

  • Set "Replace with" to 1\1\2

  • Enable "Regular expression"

  • Click "Replace All"

Image

Before:

001
001
002
002
002
003
003
003
003 

After:

101
101
102
102
102
103
103
103
103

Further reading

Share:
6,677

Related videos on Youtube

great_guest321
Author by

great_guest321

Updated on September 18, 2022

Comments

  • great_guest321
    great_guest321 over 1 year

    I have a bunch of numbers like this:

    001
    001
    002
    002
    002
    003
    003
    003
    003
    

    all the way up to 100. using the search and replace is there a way to just change the first number so that i could get it up to 1000 faster?

    I am also open to any other ideas.

    • Adam
      Adam over 8 years
      I don't understand the output you're after. Can you show what you would like 001 001 002 002 002 003 003 003 003.... to be replaced with?
    • great_guest321
      great_guest321 over 8 years
      I'm sorry, I wanted to add "1" replacing the first number witch would be 101 101 102 102 102 102 and so on.
    • Adam
      Adam over 8 years
      So 001 001 002 002 002 003 003 003 003 would become 101 101 102 102 102 103 103 103 103? Or would it become 101 001 002 002 002 003 003 003 003?
    • great_guest321
      great_guest321 over 8 years
      it would become 101 101 102 102 102 103 103 103 103 all the way up to 199.
    • Adam
      Adam over 8 years
      Would it not accomplish what you want to search for ` 0` and replace with ` 1`? (Note the leading spaces)
    • great_guest321
      great_guest321 over 8 years
      no my numbers are in columns with no space in fount of them but I see what you were getting at.
    • SΛLVΘ
      SΛLVΘ over 8 years
      Search for a ^0 regex and replace it with 1.
    • Adam
      Adam over 8 years
      ...or highlight from the end of one line through the first 0 on the next, hit ctl-c (copy) then hit ctl-f (find). Paste into the find box and into the replace with box, then change the 0 in the replace with box to a 1.
    • Adam
      Adam over 8 years
      You could also do this with extended search and replace instead of Regular Expression mode. Find \r\n0 replace with \r\n1. Turning on display of all characters (the double-struck backwards P) may help you understand what is going on there. In windows, you'll see every line is ended with a cr lf cr is \r and lf is \n.
    • great_guest321
      great_guest321 over 8 years
      Thanks for helping me figure this out I was really stumped.