@Tazhar0001 said in Find and replace a variable item:
Peter, is it possible to send you a private message of the .XML file I have? My knowledge in doing such a task is, minimal to say the least.
There are no PM on this, and I don’t advertise my email address here (avoiding spambot harvesting).
The [example data](https://community.notepad-plus-plus.org/post/50274 you showed near the start of this thread does work with the script I provided (well, I guess my previous post was missing the first line needed):
from Npp import *
def add_1(m):
return (m.group(1)) + str(int(m.group(2)) + 1) + (m.group(3))
editor.rereplace('(lootmax=")([0-9]+)(")', add_1);
Even with data like:
lootmax="2"
lootmax="4"
lootmax="6"
lootmax="1"
lootmax="5"
lootmax="9"
<tag other="x" lootmax="2" />
<tag other="y" lootmax="4" />
<tag other="z" lootmax="6" /> <other>blah</interferes>
<tag other="p" lootmax="1" />
<tag other="d" lootmax="5" />
<tag other="z" lootmax="9" />
all the lootmax="#" get one added properly.
If you need help with PythonScript
Install PythonScript (if you don’t already have it):
Plugins > Plugins Admin, check the box on ☐ PythonScript, and click
Install; restart Notepad++ as needed
Plugins > PythonScript > New script, named lootmax.py
Paste the contents of the script from this post. Save.
Set Notepad++'s active file to your file with the lootmax values. Run **Plugins > Python Script > Scripts > lootmax`; the replacement should occur.