Community
    • Login

    Mass Replace while dividing the value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    23 Posts 3 Posters 2.0k Views
    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
      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
        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
          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors