web-dev-qa-db-ja.com

notepad ++で重複を見つけてすべて削除する

複数のメールアドレスがあります。すべてを見つけて削除する必要があります(見つかったものを含む)。これはnotepad ++で可能ですか?

例:[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected],

次のような結果が必要です

[email protected], [email protected], [email protected], [email protected], [email protected], [email protected],

Notepad ++で行う方法

11
James123

変更可能な場合実行可能な行のシーケンス

  1. [編集]-> [行の操作]-> [行を辞書式に昇順で並べ替え]
  2. 検索/置換を実行:
    • 検索対象:^(.*\r?\n)\1+
    • 置換:(なし、空のまま)
    • 左下の正規表現を確認します
    • すべて置換をクリック

仕組み:並べ替えは、重複を互いの後ろに置きます。検索は行^(.*\r?\n)に一致し、\1の行をキャプチャしてから、最初の一致の後ろで1回以上(\1+を見つけようとし続けます。このような重複ブロック(存在する場合)は、何も置き換えられません。

\r?\nは、WindowsおよびUnixの行末をうまく処理する必要があります。

26
Lars Fischer

TextFXプラグインが必要です。次に、次の指示に従ってください。

Paste the text into Notepad++ (CTRL+V). ...
Mark all the text (CTRL+A). ...
Click TextFX → Click TextFX Tools → Click Sort lines case insensitive (at column)
Duplicates and blank lines have been removed and the data has been sorted alphabetically.

個人的には、notepad ++の代わりにsort -i -u source> destを使用します

3

使用できます

[TextFX]→[TextFXツール]→[行の大文字と小文字を区別しない並べ替え(列)]をクリックします。重複行と空白行が削除され、データがアルファベット順に並べ替えられました。

上記のように。ただし、アルファベット順に並べ替えられた行を削除するだけでなく、重複を空白行で置き換える必要があるため、私がそれをした方法:

REPLACE:
((^.*$)(\n))(?=\k<1>)

by

$3

これにより変換されます:

Shorts
Shorts
Shorts
Shorts
Shorts
Shorts Two Pack
Shorts Two Pack
Signature Braces
Signature Braces
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers
Signature Cotton Trousers

に:

Shorts

Shorts Two Pack

Signature Braces










Signature Cotton Trousers

それが私がそれをした方法です。なぜなら、私はそれらの行が特に必要だったからです。

0
daviddgz