• Login
Community
  • Login

HOW TO ELIMINATE THE TEXT THAT IS REPEATED WITH NOTEPAD

Scheduled Pinned Locked Moved General Discussion
3 Posts 2 Posters 1.1k 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
    ani rodet
    last edited by Sep 13, 2018, 9:11 PM

    Good afternoon friends, can you help me eliminate the text that is repeated in the lines?

    024 - This is normal text (IP) 024 - This is normal text (IP)
    ABC ABC
    test test test
    This is normal text.
    This is normal text.xxx This is normal text.
    This is normal text. xxx This is normal text.
    This is normal text. xxx This is normal text.
    This is duplicate text. 1234 This is duplicate text.
    This is duplicate text. YYYY This is duplicate text.
    This is duplicate text. JJJKKK This is duplicate text.
    This is duplicate text. PPPkl This is duplicate text.

    RESULT

    024 - This is normal text (IP)
    ABC
    test
    This is normal text.
    This is normal text.xxx
    This is normal text. xxx
    This is normal text. xxx
    This is duplicate text. 1234
    This is duplicate text. YYYY
    This is duplicate text. JJJKKK
    This is duplicate text. PPPkl

    How could I do it?

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Sep 13, 2018, 9:53 PM

      It’s hard to get everything you wanted, without getting matches you don’t want.

      Some questions that will help craft a better answer:

      • Do all the “repeated text” start at the beginning of the line? Or do you want to be able to change “Unique common. Middle common.” => “Unique common. Middle”?
      • I’m having trouble seeing to to expect “test test test” to match and delete twice, since “test test test” also matches the pattern “common middle common”
      • Does the final match always have to be at the end of the line, or could it be “Common Middle Common End” => “Common Middle End”?

      I came up with one that I think does what you intend, assuming the “common” must start the line, and no “end” allowed after a match-to-be-deleted:

      • find = (?-s)^(.+)(\h*.*?)(\h*\1\h*)+$
      • replace = \1\2

      Converts

      024 - This is normal text (IP) 024 - This is normal text (IP)
      ABC ABC
      test test test
      This is normal text.
      This is normal text.xxx This is normal text.
      This is normal text. xxx This is normal text.
      This is normal text. xxx This is normal text.
      This is duplicate text. 1234 This is duplicate text.
      This is duplicate text. YYYY This is duplicate text.
      This is duplicate text. JJJKKK This is duplicate text.
      This is duplicate text. PPPkl This is duplicate text.
      

      to

      024 - This is normal text (IP) 
      ABC 
      test 
      This is normal text.
      This is normal text.xxx
      This is normal text. xxx
      This is normal text. xxx
      This is duplicate text. 1234
      This is duplicate text. YYYY
      This is duplicate text. JJJKKK
      This is duplicate text. PPPkl
      
      1 Reply Last reply Reply Quote 0
      • A
        ani rodet
        last edited by Sep 14, 2018, 2:38 AM

        thanks you very much

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