• Login
Community
  • Login

Find & Replace sets of value with an unique of values

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 1.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.
  • L
    Luigi Giuseppe De Franceschi
    last edited by May 31, 2022, 10:29 AM

    Hi all!

    in a mine XML i have to replace these lines (example):
    <relationship identifier=“id-742789” source=“id-830939” target=“id-830997” xsi:type=“Composition”>
    <name xml:lang=“en”></name>
    </relationship>
    <relationship identifier=“id-830947” source=“id-830939” target=“id-830948” xsi:type=“Composition”>
    <name xml:lang=“en”></name>

    with this:
    <relationship identifier=“id-999999” source=“id-830939” target=“id-830997” xsi:type=“Composition”>
    <name xml:lang=“en”></name>
    </relationship>
    <relationship identifier=“id-999999” source=“id-830939” target=“id-830948” xsi:type=“Composition”>
    <name xml:lang=“en”></name>

    and after, starting from here:
    <connection identifier=“id-742788” xsi:type=“Relationship” relationshipRef=“id-742789” source=“id-742790” target=“id-742779”>
    <style lineWidth=“1”>
    <fillColor r=“0” g=“176” b=“80” a=“100”/>
    <lineColor r=“0” g=“176” b=“80” a=“100”/>
    <font name=“Sky Text” size=“10” style=“plain”>
    <color r=“0” g=“0” b=“0” a=“100”/>
    </font>
    </style>
    <sourceAttachment x=“540” y=“333”/>
    <bendpoint x=“540” y=“487”/>
    <targetAttachment x=“667” y=“487”/>
    </connection>

    with:
    <connection identifier=“id-742788” xsi:type=“Relationship” relationshipRef=“id-999999” source=“id-742790” target=“id-742779”>
    <style lineWidth=“1”>
    <fillColor r=“0” g=“176” b=“80” a=“100”/>
    <lineColor r=“0” g=“176” b=“80” a=“100”/>
    <font name=“Sky Text” size=“10” style=“plain”>
    <color r=“0” g=“0” b=“0” a=“100”/>
    </font>
    </style>
    <sourceAttachment x=“540” y=“333”/>
    <bendpoint x=“540” y=“487”/>
    <targetAttachment x=“667” y=“487”/>
    </connection>

    How i can do that?

    Best

    A 1 Reply Last reply May 31, 2022, 12:00 PM Reply Quote 0
    • A
      Alan Kilborn @Luigi Giuseppe De Franceschi
      last edited by May 31, 2022, 12:00 PM

      @luigi-giuseppe-de-franceschi

      Probably THIS helps you.

      L 1 Reply Last reply May 31, 2022, 1:41 PM Reply Quote 0
      • L
        Luigi Giuseppe De Franceschi @Alan Kilborn
        last edited by May 31, 2022, 1:41 PM

        @alan-kilborn thank you, i also looked here but in twice links doesn’t modify inside a tag but only btw brackets :(

        A 1 Reply Last reply May 31, 2022, 2:27 PM Reply Quote 0
        • A
          Alan Kilborn @Luigi Giuseppe De Franceschi
          last edited by May 31, 2022, 2:27 PM

          @luigi-giuseppe-de-franceschi said in Find & Replace sets of value with an unique of values:

          i also looked here

          Yes, that is better than my link.

          but in twice links doesn’t modify inside a tag but only btw bracket

          Not sure what that means…

          In fact, now I’m unclear on what exactly you need to do, so I’ll let someone else who does understand jump in and help.

          L 1 Reply Last reply May 31, 2022, 3:16 PM Reply Quote 0
          • L
            Luigi Giuseppe De Franceschi @Alan Kilborn
            last edited by Luigi Giuseppe De Franceschi May 31, 2022, 3:18 PM May 31, 2022, 3:16 PM

            @alan-kilborn no problem :)

            i applied a brute force approach and now i hope my xml will work:

            step 1) find <relationship and replace with <relationship>FYY ( *
            step 2) find source and replace with ) source *
            Step 3) find (?-s)(?-i:<relationship>|(?!\A)\G).?\K(?:\x20(.+?))
            with identifier=“id-999999”
            Step 4) find >FYY and replace with " "
            Step 5) find <connection and replace with <connection>FYY
            Step 6) find relationshipRef and replace with ( relationshipRef
            Step 7) find (?-s)(?-i:<connection>|(?!\A)\G).?\K(?:\x20(.+?))
            and replace with relationshipRef=“id-999999”
            Step 8) find >FYY and replace with " "
            Step 9) find ) source and replace with source

            am i mad? :D

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