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"
Before:
001
001
002
002
002
003
003
003
003
After:
101
101
102
102
102
103
103
103
103
Further reading
Related videos on Youtube
Author by
great_guest321
Updated on September 18, 2022Comments
-
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 over 8 yearsI 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 over 8 yearsI'm sorry, I wanted to add "1" replacing the first number witch would be 101 101 102 102 102 102 and so on.
-
Adam over 8 yearsSo
001 001 002 002 002 003 003 003 003
would become101 101 102 102 102 103 103 103 103
? Or would it become101 001 002 002 002 003 003 003 003
? -
great_guest321 over 8 yearsit would become 101 101 102 102 102 103 103 103 103 all the way up to 199.
-
Adam over 8 yearsWould it not accomplish what you want to search for ` 0` and replace with ` 1`? (Note the leading spaces)
-
great_guest321 over 8 yearsno my numbers are in columns with no space in fount of them but I see what you were getting at.
-
SΛLVΘ over 8 yearsSearch for a
^0
regex and replace it with1
. -
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 the0
in the replace with box to a1.
-
Adam over 8 yearsYou 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 over 8 yearsThanks for helping me figure this out I was really stumped.
-