Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Try \1 instead. – EBGreen Feb 7 '12 at 20:15
Thanks so much. (Silly of me.) – JellicleCat Feb 7 '12 at 20:46
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 '12 at 21:46
up vote 8 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
share|improve this answer

I think you need to have a token identifier. So if I modified Synetech's answer, I would change "Find" part to "foo (?'one'\w+) bar"

share|improve this answer
It would help if you can test the solution and provide an answer, Starting an answer as "i think" doesn't show confidence, and you might get down votes – SeanClt Mar 24 at 17:20
Fair enough. I was trying to add to the existing answer. – VJC Mar 24 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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