Complicated search and replace



  • 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!



  • 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


Log in to reply