• Login
Community
  • Login

Find only the duplicate value

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 3.4k 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.
  • A
    Antonsta
    last edited by Nov 21, 2018, 11:19 AM

    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

    S 1 Reply Last reply Nov 21, 2018, 1:24 PM Reply Quote 0
    • S
      Scott Sumner @Antonsta
      last edited by Nov 21, 2018, 1:24 PM

      @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
      • A
        Antonsta
        last edited by Nov 21, 2018, 2:09 PM

        @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

        S 1 Reply Last reply Nov 21, 2018, 2:12 PM Reply Quote 0
        • S
          Scott Sumner @Antonsta
          last edited by Nov 21, 2018, 2:12 PM

          @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
          • A
            Antonsta
            last edited by Nov 21, 2018, 2:32 PM

            @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

            S 1 Reply Last reply Nov 21, 2018, 3:07 PM Reply Quote 0
            • S
              Scott Sumner @Antonsta
              last edited by Scott Sumner Nov 21, 2018, 3:10 PM Nov 21, 2018, 3:07 PM

              @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
              • A
                Antonsta
                last edited by Nov 21, 2018, 3:19 PM

                @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
                • T
                  Terry R
                  last edited by Nov 22, 2018, 9:41 PM

                  @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
                  2 out of 8
                  • First post
                    2/8
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors