Notepad ++ 通配符与查找和替换一起使用

0 text-editing notepad++ format

我有一个 12 位的 MAC 地址,例如5C838F9FE398我需要替换为5C83.8F9F.E398

由于我必须使用 200 多个 MAC 地址,因此我认为使用 Notepad++ 来节省时间。是否可以使用 Notepad++ 快速完成?

LPC*_*hip 5

是的,这是可能的。

假设 macaddress 列表如下所示:

5C838F9FE398
5C838F9FE398
5C838F9FE398
5C838F9FE398
Run Code Online (Sandbox Code Playgroud)

(当然,每个都是独一无二的)

您可以使用正则表达式查找/替换。

CTRL+打开查找/替换对话框H

在 Find What 字段中,输入:^(.{4})(.{4})(.{4})
在 Replace with 字段中,输入:$1.$2.$3

在搜索模式组的底部,选择正则表达式。

现在打Replace All


解释正则表达式:

^          Only match if this happens at the beginning of a line
  (        Start of group 1 (to replace with $1)
    .{4}   Any character, 4 times
  )        End of group 1
  (        Same as above for group 2
    .{4}
  )
  (        Same as above for group 3
    .{4}
  )
Run Code Online (Sandbox Code Playgroud)

更换设置为:

 $1    These are the first 4 values found
 .     place a period next
 $2    These are the second 4 values found
 .     place a period next
 $3    These are the third 4 values found.
Run Code Online (Sandbox Code Playgroud)

此字符串之后的任何内容都将被完全忽略,并将保持存在。

于是 5C838F9FE398 test变成5C83.8F9F.E398 test