Mark or remove partly duplicate lines in Notepad++












3














Let's say i have a file like this opened in Notepad++:



email@address.com:word1
email@address.com:word2
email@address.com:word3
email@address1.com:word4
email@address2.com:word5
email@address3.com:word6
email@address3.com:word7


As you can see lines 1, 2, 3 and 6, 7 are duplicate before the ":". Is there any regex i can use to mark or remove all lines that are duplicate before the ":"?



Thx!










share|improve this question



























    3














    Let's say i have a file like this opened in Notepad++:



    email@address.com:word1
    email@address.com:word2
    email@address.com:word3
    email@address1.com:word4
    email@address2.com:word5
    email@address3.com:word6
    email@address3.com:word7


    As you can see lines 1, 2, 3 and 6, 7 are duplicate before the ":". Is there any regex i can use to mark or remove all lines that are duplicate before the ":"?



    Thx!










    share|improve this question

























      3












      3








      3


      1





      Let's say i have a file like this opened in Notepad++:



      email@address.com:word1
      email@address.com:word2
      email@address.com:word3
      email@address1.com:word4
      email@address2.com:word5
      email@address3.com:word6
      email@address3.com:word7


      As you can see lines 1, 2, 3 and 6, 7 are duplicate before the ":". Is there any regex i can use to mark or remove all lines that are duplicate before the ":"?



      Thx!










      share|improve this question













      Let's say i have a file like this opened in Notepad++:



      email@address.com:word1
      email@address.com:word2
      email@address.com:word3
      email@address1.com:word4
      email@address2.com:word5
      email@address3.com:word6
      email@address3.com:word7


      As you can see lines 1, 2, 3 and 6, 7 are duplicate before the ":". Is there any regex i can use to mark or remove all lines that are duplicate before the ":"?



      Thx!







      notepad++ regex






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 25 '18 at 23:33









      Renee De BockRenee De Bock

      183




      183






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Caution: this will only work on a sorted file.





          • Ctrl+H

          • Find what: ^([^:]+:).+R(?:.*?1.+(?:R|$))+

          • Replace with: LEAVE EMPTY

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Replace all


          Explanation:



          ^               # beginning of line
          ([^:]+:) # group 1, 1 or more NOT colon followed by a colon (i.e. email address)
          .+ # 1 or more any character but newline
          R # any kind of linebreak (ie. r, n, rn)
          (?: # start non capture group
          .*? # 0 or more any character, not greedy
          1 # backreference to group 1 (email address)
          .+ # 1 or more any character but newline
          (?:R|$) # non capture group, a ine break or end of line
          )+ # group may appear 1 or more times


          Result for given example:



          email@address1.com:word4
          email@address2.com:word5





          share|improve this answer





















          • Thank you! Works like a charm!
            – Renee De Bock
            Dec 27 '18 at 11:55










          • @ReneeDeBock: You're welcome, glad it helps.
            – Toto
            Dec 27 '18 at 13:08











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387677%2fmark-or-remove-partly-duplicate-lines-in-notepad%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Caution: this will only work on a sorted file.





          • Ctrl+H

          • Find what: ^([^:]+:).+R(?:.*?1.+(?:R|$))+

          • Replace with: LEAVE EMPTY

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Replace all


          Explanation:



          ^               # beginning of line
          ([^:]+:) # group 1, 1 or more NOT colon followed by a colon (i.e. email address)
          .+ # 1 or more any character but newline
          R # any kind of linebreak (ie. r, n, rn)
          (?: # start non capture group
          .*? # 0 or more any character, not greedy
          1 # backreference to group 1 (email address)
          .+ # 1 or more any character but newline
          (?:R|$) # non capture group, a ine break or end of line
          )+ # group may appear 1 or more times


          Result for given example:



          email@address1.com:word4
          email@address2.com:word5





          share|improve this answer





















          • Thank you! Works like a charm!
            – Renee De Bock
            Dec 27 '18 at 11:55










          • @ReneeDeBock: You're welcome, glad it helps.
            – Toto
            Dec 27 '18 at 13:08
















          1














          Caution: this will only work on a sorted file.





          • Ctrl+H

          • Find what: ^([^:]+:).+R(?:.*?1.+(?:R|$))+

          • Replace with: LEAVE EMPTY

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Replace all


          Explanation:



          ^               # beginning of line
          ([^:]+:) # group 1, 1 or more NOT colon followed by a colon (i.e. email address)
          .+ # 1 or more any character but newline
          R # any kind of linebreak (ie. r, n, rn)
          (?: # start non capture group
          .*? # 0 or more any character, not greedy
          1 # backreference to group 1 (email address)
          .+ # 1 or more any character but newline
          (?:R|$) # non capture group, a ine break or end of line
          )+ # group may appear 1 or more times


          Result for given example:



          email@address1.com:word4
          email@address2.com:word5





          share|improve this answer





















          • Thank you! Works like a charm!
            – Renee De Bock
            Dec 27 '18 at 11:55










          • @ReneeDeBock: You're welcome, glad it helps.
            – Toto
            Dec 27 '18 at 13:08














          1












          1








          1






          Caution: this will only work on a sorted file.





          • Ctrl+H

          • Find what: ^([^:]+:).+R(?:.*?1.+(?:R|$))+

          • Replace with: LEAVE EMPTY

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Replace all


          Explanation:



          ^               # beginning of line
          ([^:]+:) # group 1, 1 or more NOT colon followed by a colon (i.e. email address)
          .+ # 1 or more any character but newline
          R # any kind of linebreak (ie. r, n, rn)
          (?: # start non capture group
          .*? # 0 or more any character, not greedy
          1 # backreference to group 1 (email address)
          .+ # 1 or more any character but newline
          (?:R|$) # non capture group, a ine break or end of line
          )+ # group may appear 1 or more times


          Result for given example:



          email@address1.com:word4
          email@address2.com:word5





          share|improve this answer












          Caution: this will only work on a sorted file.





          • Ctrl+H

          • Find what: ^([^:]+:).+R(?:.*?1.+(?:R|$))+

          • Replace with: LEAVE EMPTY

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Replace all


          Explanation:



          ^               # beginning of line
          ([^:]+:) # group 1, 1 or more NOT colon followed by a colon (i.e. email address)
          .+ # 1 or more any character but newline
          R # any kind of linebreak (ie. r, n, rn)
          (?: # start non capture group
          .*? # 0 or more any character, not greedy
          1 # backreference to group 1 (email address)
          .+ # 1 or more any character but newline
          (?:R|$) # non capture group, a ine break or end of line
          )+ # group may appear 1 or more times


          Result for given example:



          email@address1.com:word4
          email@address2.com:word5






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 26 '18 at 10:07









          TotoToto

          3,62591226




          3,62591226












          • Thank you! Works like a charm!
            – Renee De Bock
            Dec 27 '18 at 11:55










          • @ReneeDeBock: You're welcome, glad it helps.
            – Toto
            Dec 27 '18 at 13:08


















          • Thank you! Works like a charm!
            – Renee De Bock
            Dec 27 '18 at 11:55










          • @ReneeDeBock: You're welcome, glad it helps.
            – Toto
            Dec 27 '18 at 13:08
















          Thank you! Works like a charm!
          – Renee De Bock
          Dec 27 '18 at 11:55




          Thank you! Works like a charm!
          – Renee De Bock
          Dec 27 '18 at 11:55












          @ReneeDeBock: You're welcome, glad it helps.
          – Toto
          Dec 27 '18 at 13:08




          @ReneeDeBock: You're welcome, glad it helps.
          – Toto
          Dec 27 '18 at 13:08


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1387677%2fmark-or-remove-partly-duplicate-lines-in-notepad%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

          Eduardo VII do Reino Unido