Reputation: 499
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
Upvotes: 0
Views: 319
Reputation: 91518
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)
Upvotes: 1