For the benefit of future readers:-
@Toto's answer may replace other numbers as well, so I am posting another PythonScript here to match <sup>
, followed by a [
bracket and then the number sought as per the question. You can run a python script within the PythonScript plugin of Notepad++ for that.
If it is not yet installed, install it via Plugins Admin. To install the PythonScript plugin in Notepad++, navigate to Plugins > Plugins Admin. Check the box next to PythonScript and click Install. Notepad++ will restart, and after that, you can find the plugin in the Plugins menu.
Create a script (Plugins >> PythonScript >> New Script)
Copy this code and save the file (for example increment.py):
# encoding=utf-8
from Npp import *
def custom_replace_func(m):
new_text = "<sup>\[{}".format(custom_replace_func.counter)
custom_replace_func.counter += custom_replace_func.increment
return new_text
custom_replace_func.counter = 1 # starting value
custom_replace_func.increment = 1
editor.rereplace(r'<sup>\[(\d+)', custom_replace_func)
Open the file you want to modify
Run the script (Plugins >> PythonScript >> Scripts >> increment)
Then, in the result obtained after the above, put the cursor before the first <sup>
and hit Ctrl+H and in the pop-up, type <sup>.*?\[
in the "Find" field and <sup>[
in the "Replace with" field and hit “Replace all” to get rid of the \
after every <sup>