I have a piece of generated text on Notepad++ that I would like to make some find/replace with Regex...

The text originally is like this:

private static final int ClientCode(removingQuotes(fields[4]));
private static final int InvoiceDate(removingQuotes(fields[5]));
private static final int IssueDate(removingQuotes(fields[6]));

I want to change the (removingQuotes(fields[6])) of each line and replacing to = n - where n is the number inside square brackets.

In the end, the result would be like this:

private static final int SeqNum = 2;
private static final int CarSegNum = 3;

I already have a regular expression that matches (removingQuotes(fields[6])). The regex I have is below:


However, I don't know what to place in the Replace with: field, in order to get the number from the previous string and keep it. Today I need to change the number for each occurrence - and I have thousands of lines to do it.

Is there a way to do it?

  • You could also simply search and replace (removingQuotes(fields[ with ` = ` and replace ])) with [null]
    – Alex M
    Apr 17, 2019 at 19:46

1 Answer 1


You need to slightly change your expression to:
\(removingQuotes\(fields\[(\d+) \]\)\)
This way you create a capturing group which you can refer to later.

And replace to:
= $1

You must log in to answer this question.

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