in reply to Converting MAC Address
my $foo = "0:0A:0C:B:B8:F"; $foo =~ s/([0-9A-F])+:?/length($1) < 2?"0$1":$1/ge;
update:let's try again
The problem with the initial one was where the + was which would match a series of [0-9A-F], but only the last character would be captured, so the length would always be one and it just happened that it was adding a 0 to the front of that and I missed the B8 thing initially. so ++ to you for the catch.my $foo = "0:0A:0C:B:B8:F"; $foo =~ s/([0-9A-F]+):?/length($1) < 2?"0$1":$1/ge;
Which brings the question, which maybe I am not thinking but why would it capture only the last character instead of only the initial character?
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Converting MAC Address
by HiFoo (Scribe) on Jan 11, 2003 at 00:19 UTC | |
by BrowserUk (Patriarch) on Jan 11, 2003 at 00:43 UTC | |
by Enlil (Parson) on Jan 11, 2003 at 01:59 UTC | |
by theorbtwo (Prior) on Jan 11, 2003 at 01:08 UTC | |
by poj (Abbot) on Jan 11, 2003 at 10:49 UTC |