Hi monks,
I'm searching a way to insert colons into a mac address in the format:
525400eb8b36
to get:
52:54:00:eb:8b:36
one way is this:
$mac = join(":", /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
but it's _very_ ugly.
This also works:
$mac = join(':', unpack('A2A2A2A2A2A2', $_));
but I would prefer a regex; is there a way to make the regex above more compact?
How would you perform this tasK?
Thanks,
bye.
In reply to Insert colons into a MAC address by mantager
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |