如何在 Notepad++ 中执行此操作?

如何在 Notepad++ 中执行此操作?

我有数千行如下所示的内容:

Username | Password | Account Status | Region | Email | Summoner Name | BE | RP | RP Refunds | Level | Curr Rank | Prev Rank | Champs | Skins | Last Played

这些字段不是文字字符串,例如“电子邮件”是真实的电子邮件,“密码”是真实的密码,“用户名”是真实的用户名等Needhelpx5 | xxxyyy | Valid

我想让它看起来像这样:

Email | Password

例子:[电子邮件保护]| xxxyyy111

答案1

  • Ctrl+H
  • 找什么:^[^|]+\|([^|]+)(?:\|[^|]+){2}\|([^|]+).+$
  • 用。。。来代替:$2|$1
  • 查看 环绕
  • 查看 正则表达式
  • 取消选中 . matches newline
  • Replace all

解释:

^                     # beginning of line
    [^|]+               # 1 or more any character that is not a pipe
    \|                  # a pipe
    ([^|]+)             # group 1, 1 or more any character that is not a pipe (i.e. password)
    (?:                 # non capture group
        \|                # a pipe
        [^|]+             # 1 or more any character that is not a pipe
    ){2}                # end group, must appear twice
    \|                  # a pipe
    ([^|]+)             # group 2, 1 or more any character that is not a pipe (i.e. email)
    .+                  # 1 or more any character but newline
$                     # end of line

替代品:

$2              # content of group 2 (email)
|               # a pipe
$1              # content of group 1 (password)

截图(之前):

在此处输入图片描述

截图(之后):

在此处输入图片描述

相关内容