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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login