Mass Replace while dividing the value
-
@Ekopalypse I removed the DT stuff on top of the file and still get those errors
Traceback (most recent call last): File "C:\Program Files\Notepad++\plugins\PythonScript\scripts\Tests\calculate4.py", line 4, in <module> root = ET.XML(editor.getText()) File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1311, in XML parser.feed(text) File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1659, in feed self._raiseerror(v) File "C:\Program Files\Notepad++\plugins\PythonScript\lib\xml\etree\ElementTree.py", line 1523, in _raiseerror raise err xml.etree.ElementTree.ParseError: encoding specified in XML declaration is incorrect: line 1, column 30
-
def regexmath(m): return "{}".format(int(float(m.group())*0.5)) editor.rereplace('(?<=<max_hp>)\d+\.*\d*(?=</max_hp>)', regexmath)
will replace the ones without surrounded by quotes.
editor.rereplace('(?<=<max_hp>")\d+\.*\d*(?="</max_hp>)', regexmath)
will replace if surrounded by quotes.
-
@Ekopalypse thank you very much kind sir, it works, have a great and amazing day