Reputation: 23
Is it possible to use the value of a regex in the "FIND" part of a find/replace in Notepad++ ?
Here's what i have :
FIND: ^.{105}.*(.)
REPLACE: \r\n
the value to replace is the 106th character in my file. let's say it's an ~
now the find/replace should find & replace all occurrence of ~ and replace all of them by '\r\n' (the ~ represent the end of line character)
It doesn't work, it replace the whole string instead of the 106th char and only replace once instead of multiple time on the file.
The whole purpose of this is to have this set on a hotkeyed macro so it can be done quickly and often.
Upvotes: 0
Views: 546
Reputation: 91518
You could do:
Find what: ^(.{105}).
Replace with: $1\r\n
Make sure you have checked Regular expression
BUT NOT dot matches newline
then click on Replace all
This will capture in group 1 the first 105 characters in each line.
Upvotes: 0
Reputation: 96
I think you want something along these lines:
Find: ^(.{105}.)
Replace: \1\r\n
You need to wrap the thing in a capture group otherwise your ^
will force it to only match the beginning of the line. You'll also need to include the first capture group as part of the replacement string so it won't nuke the entire matching.
Upvotes: 2