Community
    • Login

    Mass Replace while dividing the value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 3 Posters 4.6k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Caddy DC Offline
      Caddy D @Ekopalypse
      last edited by

      @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
      
      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE Offline
        Ekopalypse @Caddy D
        last edited by Ekopalypse

        @Caddy-D

        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.

        Caddy DC 1 Reply Last reply Reply Quote 1
        • Caddy DC Offline
          Caddy D @Ekopalypse
          last edited by

          @Ekopalypse thank you very much kind sir, it works, have a great and amazing day

          1 Reply Last reply Reply Quote 1

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors