Community
    • Login

    Find only the duplicate value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 3.3k 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.
    • AntonstaA
      Antonsta
      last edited by

      Hey. I want to find the duplicate value and to copy those duplicate values.

      Eg:
      Input:
      New York
      Dubai
      Japan
      France
      New York
      Qatar
      Japan

      Output:
      New York
      Japan

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Antonsta
        last edited by

        @Antonsta

        Here’s a possible way to do it:

        Invoke Mark dialog (Search (menu) -> Mark…) <–Suggestion: Tie ctrl+m to this action
        Find what zone: (?-is)^(.+)(?s)(?=.*?^\1$)
        Wrap around checkbox: ticked
        Mark line checkbox: ticked
        Match whole word only checkbox: unticked
        Action: Press the Find All button

        Next invoke Search (menu) -> Bookmark -> Copy Bookmarked Lines

        1 Reply Last reply Reply Quote 1
        • AntonstaA
          Antonsta
          last edited by

          @Scott-Sumner said:

          Action
          Hey,

          I’m not having the “Mark line” option. Here’s the screenshot. I’m using 7.6 version.

          Thanks alot for replying

          Scott SumnerS 1 Reply Last reply Reply Quote 0
          • Scott SumnerS
            Scott Sumner @Antonsta
            last edited by

            @Antonsta

            I think I was misquoted!!! :-D

            It would be Bookmark line in your case…it really seems that you might have guessed that or even tried it before posting. :-)

            1 Reply Last reply Reply Quote 3
            • AntonstaA
              Antonsta
              last edited by

              @Scott-Sumner said:
              I think I was misquoted!!! :-D
              Yeah, I guessed it :)
              But, It’s not working properly? It’s marking the entire document :(
              Check out the screenshot

              Scott SumnerS 1 Reply Last reply Reply Quote 0
              • Scott SumnerS
                Scott Sumner @Antonsta
                last edited by Scott Sumner

                @Antonsta said:

                It’s marking the entire document

                Yea, sometimes with a lot of data (I’m looking at your line numbers) the search/mark engine gets overwhelmed and chokes! :(

                What if you try sorting your data first?

                1 Reply Last reply Reply Quote 0
                • AntonstaA
                  Antonsta
                  last edited by

                  @Scott-Sumner said:

                  What if you try sorting your data first?

                  Yes, Sorted it and tried again. Still, it’s marking the entire document :(
                  Is there any plugins that can do this? :((

                  1 Reply Last reply Reply Quote 0
                  • Terry RT
                    Terry R
                    last edited by

                    @Antonsta
                    Unfortunately, even when the data is sorted, as you found out the regex still caused the same issue. That’s because it’s still trying to search forward over multiple line.

                    When the data is sorted this isn’t necessary anymore as duplicates will appear on consecutive lines.

                    Thus the regex can be changed to:
                    (?-is)^(.+)\R\K(\1$)

                    So this will ONLY look for 2 lines together with the same data. The use of the \K is to forget the first line so the line that gets marked is the duplicate line ONLY.

                    @guy038 gave a detailed rundown on this issue and ways to circumvent it. Have a look at:
                    https://notepad-plus-plus.org/community/topic/16489/delete-both-duplicates-regexp-macro/15?page=1

                    Cheers
                    Terry

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