如何在 Notepad++ 中為每行添加不同內容的文字?

如何在 Notepad++ 中為每行添加不同內容的文字?

我有以下文字:

[email protected]:Golden-Ball
[email protected]:SilverBall
[email protected]:Copper_Ball
[email protected]:Encourage
[email protected]:Not-Engaged

我想得到結果:

yahoo.com:Email.yahoo.com
epfedu.fr:Email.epfedu.fr
staplesnet.us:Email.staplesnet.us
mail.montclair.edu:Email.mail.montclair.edu
stu.howardcollege.edu:Email.stu.howardcollege.edu

我該怎麼做?

答案1

點擊Ctrl+H

  • 找什麼:^.+(@.+)(:).+?$
  • 用。$1$2Email\.$1
  • 將搜尋模式設定為正規表示式

圖片:

答案2

  • Ctrl+H
  • 找什麼:^.+@([^:]+):.+$
  • 用。$1:Email.$1
  • 查看 環繞
  • 查看 正規表示式
  • 取消選取 . matches newline
  • Replace all

解釋:

^               # beginning of line
  .+            # 1 or more any character but newline
  @             # literally @
  ([^:]+)       # group 1, 1 or more any character that is not colon
  :             # a colon
  .+            # 1 or more any character but newline
$

替代品:

$1          # content of group 1
:           # a colon
Email       # literally Email
.           # a dot
$1          # content of group 1

截圖(之前):

在此輸入影像描述

截圖(之後):

在此輸入影像描述

相關內容