Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How do i remove a duplicate line after a particular combination?

    Help wanted · · · – – – · · ·
    2
    3
    42
    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.
    • Tasos Akrido
      Tasos Akrido last edited by Tasos Akrido

      Let’s say i have this in my notepad:

      <path>./gamename1567/gamename1567.cue</path>
      <image>C:/images/gamename1567/gamename1567.png</image>
      

      And i want to do this:

      <path>./gamename1567/gamename1567.cue</path>
      <image>C:/images/gamename1567.png</image>
      

      You can see the “gamename” is mentioned twice in the <path> section and i need that as is. But i want the second “gamename” removed if it’s in the <image> section.

      There are thousands of lines with different “gamenames” in that text file. So i can’t just replace

      “gamename1567.png</image>”

      with

      “</image>”

      Because that will affect only one game in the list. I’m stuck!

      1 Reply Last reply Reply Quote 0
      • guy038
        guy038 last edited by

        Hello, @tasos-akrido and All,

        Very easy with regular expressions !

        • Open the Replace dialog ( Ctrl + H )

        • SEARCH (?-s)^(\h*<image>C:/images)/.+(/.*\.png</image>)

        • REPLACE \1\2

        • Tick, preferably, the Wrap around option

        • Select the Regular expression search mode

        • Click once on the Replace All button or several times on the Replace button

        Voila !

        So, for instance, the text :

        <path>./gamename1567/gamename1567.cue</path>
        <image>C:/images/gamename1567/gamename1567.png</image>
        
        <path>./gamename37/gamename37.cue</path>
        <image>C:/images/gamename37/gamename37.png</image>
        
        <path>./gamename12345/gamename12345.cue</path>
        <image>C:/images/gamename12345/gamename12345.png</image>
        

        would be changed into :

        <path>./gamename1567/gamename1567.cue</path>
        <image>C:/images/gamename1567.png</image>
        
        <path>./gamename37/gamename37.cue</path>
        <image>C:/images/gamename37.png</image>
        
        <path>./gamename12345/gamename12345.cue</path>
        <image>C:/images/gamename12345.png</image>
        

        In addition this regex S/R can also manage this case :

        <path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path>
        <image>C:/images/gamename1567/aaaaa/bbbbb/ccccc/gamename1567.png</image>
        

        And, after replacement, you would get :

        <path>./gamename1567/aaaaa/bbbbb/ccccc/gamename1567.cue</path>
        <image>C:/images/gamename1567.png</image>
        

        Nice, isn’t it ?

        Best regards

        guy038

        1 Reply Last reply Reply Quote 2
        • Tasos Akrido
          Tasos Akrido last edited by

          Thank you, it works :)

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors