Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I want to use Notepad++ to find/replace large chunks of code, but a hefty part of it deals with arrays. How can I put a "variable" in Notepad++'s Find/Replace window so that part of it can be saved and not overwritten?

The below example isn't perfect, as it could be converted using two simple find/replace searches, but I'd like to do something to the effect of Find: o[*] and Replace: p*.




What I need:

share|improve this question
up vote 4 down vote accepted

If you enable the Regular expression radio button, you can use parenthesis to hold values.

Whatever is contained within the first () gets stored in \1, the second in \2 and so on.

Here's a basic illustration of that for your example.

variable replacement in notepad++![][1]
The \d matches a digit. [ and ] have to be escaped with \ because they are special characters.

share|improve this answer
Brilliant, this is exactly what I need. I haven't quite taken the jump to learn regex yet, but I'm getting there. :) Thank you! – Vaindil Sep 19 '13 at 0:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .