I have a 12-digit MAC address such as 5C838F9FE398
which I need to replace with 5C83.8F9F.E398
Since I have to this for more than 200 MAC addresses I thought to use Notepad++ to save time. Is it possible to do it quickly with Notepad++?
Yes, this is possible.
Assuming the list of macaddresses look like this:
5C838F9FE398
5C838F9FE398
5C838F9FE398
5C838F9FE398
(where each is unique of course)
You can find/replace using regex.
Open the Find/Replace dialog by pressing CTRL+H.
In the Find What field, enter: ^(.{4})(.{4})(.{4})
In the Replace with field, enter: $1.$2.$3
At the bottom in the Search Mode group, select Regular Expression.
Now hit 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}
)
Replacing is setup as:
$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.
Anything after this string is completely ignored, and will remain present.
So 5C838F9FE398 test
becomes 5C83.8F9F.E398 test
([0-9A-F]{4})
instead of each occurrence of (.{4})
. This would be particularly necessary if there is other information in the file besides the MAC addresses, and even more so if the addresses are not at the start of the file: in the latter case you need something like \<([0-9A-F]{4})([0-9A-F]{4})([0-9A-F]{4})\>
as the search string.