如何刪除行中分隔符號之前的重複使用者名稱?

如何刪除行中分隔符號之前的重複使用者名稱?

我想刪除分隔符號 : 之前的行中重複的用戶名,並僅保留這些用戶名的第一行。

線路範例:

zzzz:000000zl
zzzz:000000zl!
zzzz:000000zl1
zzzz:000000zl123
zzzz:000000zl69
zzzz:000000zl?
AdSFF12:Sample198445
AdSFF12:Sample198445!
AdSFF12:Sample198445#
AdSFF12:Sample198445$
AdSFF12:Sample1984456
TestOf13:Smpletest1211
TestOf13:Smpletest1211!
TestOf13:Smpletest1211#
TestOf13:Smpletest1211$
TestOf13:Smpletest12112
TestOf13:Smpletest561
TestOf13:Smpletest561!
TestOf13:Smpletest561#
TestOf13:Smpletest561$
TestOf13:Smpletest5612
TestOf13:SmpletestZ2
TestOf13:SmpletestZ2!
TestOf13:SmpletestZ2#
TestOf13:SmpletestZ2$
TestOf13:SmpletestZ23
TestOf13:Smpletestz3qwe
TestOf13:Smpletestz3qwe!
TestOf13:Smpletestz3qwe1
TestOf13:Smpletestz3qwe123
TestOf13:Smpletestz3qwe69
TestOf13:Smpletestz3qwe?

所需結果:

zzzz:000000zl
AdSFF12:Sample198445
TestOf13:Smpletest1211

非常感謝您的幫助,提前謝謝您<3。

答案1

  • Ctrl+H
  • 找什麼:^((.*?:).+\R)(\2.+\R)+
  • 用。$1
  • 查看 環繞
  • 查看 正規表示式
  • 取消選取 . matches newline
  • Replace all

解釋:

^       # beginning of line
    (       # start group 1
        (       # start group 2
            .*?     # 0 or more any character but newline, not greedy
            :       # a colon
        )       # end group 2
        .+      # 0 or more any character but newline
        \R      # any kind of linebreak (i.e. \r, \n, \r\n)
    )       # end group 1
    (       # group 3, you can use (?: for non capture group
        \2      # back reference to group 2 (i.e. the part before the colon)
        .+      # 0 or more any character but newline
        \R      # any kind of linebreak (i.e. \r, \n, \r\n)
    )+      # end of group 3, may appear 0 or more times

替代品:

$1          # content of group 1, the value of the first line

截圖(之前):

在此輸入影像描述

截圖(之後):

在此輸入影像描述

相關內容