your programing

Notepad ++에서 중복 행 제거

lovepro 2020. 10. 3. 11:24
반응형

Notepad ++에서 중복 행 제거


Notepad ++에서 중복 된 행을 제거하고 한 줄만 남겨 둘 수 있습니까?


Notepad ++는 줄별로 정렬하고 동시에 중복 된 줄을 제거하려는 경우이를 수행 할 수 있습니다.

TextFX 플러그인이 필요합니다. 이전 버전의 Notepad ++에 포함되어 있었지만 최신 버전이있는 경우으로 이동하여 메뉴에서 추가 할 수 있습니다 Plugins -> Plugin Manager -> Show Plugin Manager -> Available tab -> TextFX -> Install. 어떤 경우에는라고도 할 수 TextFX Characters있지만 이것은 동일합니다.

이제 필요한 확인란과 버튼이 아래의 메뉴에 나타납니다 TextFX -> TextFX Tools.

"sort outputs only unique ..."가 선택되어 있는지 확인하십시오. 다음으로 텍스트 블록 을 선택합니다 (전체 문서를 선택하려면 Ctrl+ A). 마지막으로 "대소 문자 구분"또는 "대소 문자 구분 없음"을 클릭합니다.

n ++의 메뉴 레이아웃


Notepad ++ 버전 6부터 검색 및 바꾸기 대화 상자에서이 정규식을 사용할 수 있습니다.

^(.*?)$\s+?^(?=.*^\1$)

그리고 아무것도 바꾸지 마십시오 . 이렇게하면 모든 중복 행에서 파일의 마지막 항목이 남습니다.

이를 위해 정렬이 필요하지 않으며 중복 행은 파일의 어느 위치 에나있을 수 있습니다!

"정규식"및 ". 개행과 일치"옵션을 확인해야합니다.

메모장 ++ 바꾸기 대화

  • ^ 줄의 시작과 일치합니다.

  • (.*?)모든 문자를 0 번 이상 일치하지만 가능한 한 적습니다 (행에서 정확히 일치하며 ". 개행 일치"옵션 때문에 필요함). 일치하는 행이 저장됩니다.\1

  • $ 줄의 끝과 일치합니다.

  • \s+?^ 이 부분은 다음 행이 시작될 때까지 모든 공백 문자 (개행 문자!)와 일치합니다. ==> 이것은 일치 된 행 뒤의 개행 문자를 제거하므로 교체 후에 빈 행이 없습니다.

  • (?=.*^\1$)이것은 긍정적 인 예견 주장입니다. 이것은이 정규식에서 중요한 부분이며, 파일의 다른 곳에서 정확히 동일한 행이 뒤에 오는 경우에만 행이 일치 (제거)됩니다.


행이 서로 바로 뒤에 있으면 정규식 바꾸기를 사용할 수 있습니다.

검색 패턴 : ^(.*\r?\n)(\1)+

다음으로 교체 : \1


메모장 ++

-> 창 바꾸기

검색 모드에서 정규식 라디오 버튼을 선택했는지 확인하십시오.

무엇을 찾다:

^ (. *) (\ r? \ n \ 1) + $

다음으로 교체 :

$ 1

전에:

그리고 우리는 거기에서 생각합니다

그리고 우리는 거기에서 생각합니다

하나의 선

해도 될까요

해도 될까요

후:

그리고 우리는 거기에서 생각합니다

하나의 선

해도 될까요


If you don't care about row order (which I don't think you do), then you can use a Linux/FreeBSD/Mac OS X/Cygwin box and do:

$ cat yourfile | sort | uniq > yourfile_nodups

Then open the file again in Notepad++.


The latter versions of Notepad++ do not apparently include the TextFX plugin at all. In order to use the plugin for sorting/eliminating duplicates, the plugin must be either downloaded and installed (more involved) or added using the plugin manager.

A) Easy way (as described here).

Plugins -> Plugin Manager -> Show Plugin Manager -> Available tab -> TextFX Characters -> Install

B) More involved way, if another version is needed or the easy way does not work.

  1. Download the plugin from SourceForge:

    http://downloads.sourceforge.net/project/npp-plugins/TextFX/TextFX%20v0.26/TextFX.v0.26.unicode.bin.zip

  2. Open the zip file and extract NppTextFX.dll

  3. Place NppTextFX.dll in the Notepad++ plugins directory, such as:
    C:\Program Files\Notepad++\plugins

  4. Start Notepad++, and TextFX will be one of the file menu items (as seen in Answer #1 above by Colin Pickard)

After installing the TextFX plugin, follow the instructions in Answer #1 to sort and remove duplicates.

Also, consider setting up a keyboard shortcut using Settings > Shorcut mapper if you use this command frequently or want to replicate a keyboard shortcut, such as F9 in TextPad for sorting.


You may need a plugin to do this. You can try the command line cc.ddl(delete duplicate lines) of ConyEdit. It is a cross-editor plugin for the text editors, including Notepad++.

With ConyEdit running in background, follow the steps below:

  1. enter the command line cc.ddl at the end of the text.
  2. copy the text and the command line.
  3. paste, then you will see what you want.

Example
여기에 이미지 설명 입력


None worked for me.

A solution is:

Replace

^(.*)\s+(\r?\n\1\s+)+$

with

\1

Search for the regular expression: \b(\w+)\b([\w\W]*)\b\1\b

Replace it with: $1$2

Hit the Replace button until there are no more matches for the regular expression in your file.


The plugin manager is currently unavailable (does not come with the distribution) for Notepad++. You must install it manually (https://github.com/bruderstein/nppPluginManager/releases) and even if you do, a lot of the plugins are not available anymore (no TextFX) plugin.

Maybe there is another plugin which contains the required functionality. Other than that, the only way to do it in Notepad++ is to use some special regex for matching and then replacing (Ctrl + FReplace tab).

Although there are many functionalities available via Edit menu item (trimming, removing empty lines, sorting, converting EOL) there is no "unique" operation available.

Windows 10이있는 경우 Bash활성화하고 (Microsoft Store에 Ubuntu를 입력하고 설명의 지침에 따라 설치하기 만하면됩니다) cat your_file.txt | sort | uniq > your_file_edited.txt. 물론 "your_file.txt"와 동일한 작업 디렉토리에 있거나 경로를 통해 참조해야합니다.

참고 URL : https://stackoverflow.com/questions/3958350/removing-duplicate-rows-in-notepad

반응형