In Notepad++, I want to perform a find-and-replace, providing a variable in the 'Replace with' field, which references a match from the 'Find what' field. Any ideas?

I tried supplying (find) foo (\w) bar (replace) foo baz ($1) bar qux. That didn't work.

link|improve this question

3  
Try \1 instead. – EBGreen Feb 7 at 20:15
Thanks so much. (Silly of me.) – JellicleCat Feb 7 at 20:46
1  
Easy rep there if someone wants to write up a nice answer. I don't use Notepad++ so I didn't make it an answer. I do however use google and figured the OP would appreciate something that would solve the issue even if it wasn't a proper answer. – EBGreen Feb 7 at 21:46
feedback

1 Answer

up vote 2 down vote accepted

Notepad++ uses standard POSIX regular expressions. As such, backreferences should use the slash instead of the dollar-sign:

Find    : foo (\w) bar
Replace : foo baz (\1) bar qux
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.