0
Input:
3
9
16

I need an output file which adds a constant 10 to every element in input-

Output:
13
19
26

Is there a quick way to evaluate expressions in Notepad++? I tried a couple of things, including:

Search: [0-9]+
Replace: $0+10

But the output I get is:

3+10
9+10
16+10
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Tushar
  • 415
  • 2
  • 16
  • Would be interesting to see if there is a way to edit a backreference without the use of some scripting plugin. Though I doubt it =). Here are some related questions I found that might provide some insight: [here](https://stackoverflow.com/q/20506990/9758194) and [here](https://superuser.com/q/968315/1059206) – JvdV Feb 25 '20 at 16:32
  • **Duplicate of [Notepad++ Find/Replace number with Increment Value](https://stackoverflow.com/questions/37300462/)** – Wiktor Stribiżew Feb 28 '20 at 19:00

1 Answers1

1

You can run a python script within the PythonScript plugin.

If it is not yet installed, follow this guide

Create a script (Plugins >> PythonScript >> New Script)

Copy this code and save the file (for example calculate.py):

import re
def calculate(match):
    return '%s' % (str(int(match.group(1)) + 10))

editor.rereplace('(\d+)', calculate)
  • Open the file you want to change
  • Run the script (Plugins >> PythonScript >> Scripts >> calculate)
  • Done
Toto
  • 89,455
  • 62
  • 89
  • 125