Add character to every number via Regex in Notepad++
I have a very basic question which i just can not get my head around. I do have a text document like this:
This is 5 a test!
This 3 is a test!
This is a 9 test!
and i want it to look like this:
This is 5c a test!
This 3c is a test!
This is a 9c test!
Means i want to add a 'c' to every number i find. I tried this:
Find what: [0-9]+]
Replace with: $1c
Search Mode: Regular expression
but i am obviously doing something wrong because it is not working. Help would be appreciated. Thank you!
You almost got it right.
You want to search for ([0-9]+)
And replace that with $1c
You use ( )
to create a capture group, so $1 works.
Alternatively, you can replace with $0c
instead, then you don't need to use a capture group.
- Ctrl+H
- Find what:
\d+
- Replace with:
$0c
- check Wrap around
- check Regular expression
- Replace all
Result for given example:
This is 5c a test!
This 3c is a test!
This is a 9c test!