superfrink has asked for the wisdom of the Perl Monks concerning the following question:
0:13:46:b:4:31 # input 00:13:46:0b:04:31 # expected output
$mac =~ s/(^|:)([\da-f])(:|$)/${1}0${2}${3}/g;
0:13:46:b:4:31 # input 00:13:46:0b:4:31 # produced 00:13:46:0b:04:31 # expected
my @parts = split /:/ , $mac; foreach (@parts) { if (length == 1) { $_ = "0" . $_; } } $mac = join ":" , @parts;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex overlap in MAC address
by ikegami (Patriarch) on Sep 11, 2006 at 19:23 UTC | |
by Skeeve (Parson) on Sep 11, 2006 at 20:06 UTC | |
by ikegami (Patriarch) on Sep 11, 2006 at 20:48 UTC | |
by Skeeve (Parson) on Sep 12, 2006 at 07:11 UTC | |
by Anonymous Monk on Sep 12, 2006 at 08:53 UTC | |
by ikegami (Patriarch) on Sep 12, 2006 at 19:11 UTC | |
|
Re: Regex overlap in MAC address
by VSarkiss (Monsignor) on Sep 11, 2006 at 20:56 UTC | |
|
Re: Regex overlap in MAC address
by jwkrahn (Abbot) on Sep 11, 2006 at 20:12 UTC | |
by Skeeve (Parson) on Sep 11, 2006 at 20:28 UTC |