HOW TO ELIMINATE THE TEXT THAT IS REPEATED WITH NOTEPAD
-
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. PPPklHow could I do it?
-
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
-
thanks you very much