• Login
Community
  • Login

Complicated search and replace

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 2.2k 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.
  • N
    Nozomu Ezomori
    last edited by Jan 27, 2016, 11:10 PM

    Hello, I have lots of texts that looks like this:

    <array name=“mRomPawnEquipItemId” type=“s16” count=“11”>
    <s16 value=“396”/>
    <s16 value=“491”/>
    <s16 value=“560”/>
    </array>

    <array name=“mRomPawnEquipItemId” type=“s16” count=“11”>
    <s16 value=“667”/>
    <s16 value=“971”/>
    <s16 value=“860”/>
    </array>

    And I would love to have them all converted to this:

    <array name=“mRomPawnEquipItemId” type=“s16” count=“11”>
    <s16 value=“111”/>
    <s16 value=“111”/>
    <s16 value=“111”/>
    </array>

    Is there any way to have a search and replace look ONLY for a start and end line as a criteria for search and replace (since middle is never static), example:

    <array name=“mRomPawnEquipItemId” type=“s16” count=“11”>
    (IGNORE ANYTHING IN MIDDLE)
    </array>

    Then do a replace based only on START: <array name=“mRomPawnEquipItemId” type=“s16” count=“11”> and END </array> to this:

    <array name=“mRomPawnEquipItemId” type=“s16” count=“11”>
    <s16 value=“111”/>
    <s16 value=“111”/>
    <s16 value=“111”/>
    </array>

    All i want to do do is have lots different textblocks with similar start and end array to be changed to what my example show.

    Can Notepad++ do this or any plugin or any other software? Any example on how to achive this would be amazing!

    C 1 Reply Last reply Jan 28, 2016, 11:18 PM Reply Quote 0
    • C
      Claudia Frank @Nozomu Ezomori
      last edited by Jan 28, 2016, 11:18 PM

      Hello @Nozomu-Ezomori,

      this depends highly on the real file content. I assume, from the given example, that it is a xml file, correct?
      If so, a script, written in a language which can handle xml documents, can easily do it as long as the xml node
      has an unique identifier like the parent node, or its node name etc…
      I assume it can also be done by using the mighty regular expressions if there is a pattern which can be identified.

      So, without having the real content, we can only give suggestions on how to solve it.

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors