Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

RE: (2) One for the regexp fans (nnnn:nnnn:nnnn)

by ybiC (Prior)
on Aug 04, 2000 at 15:05 UTC ( #26166=note: print w/replies, xml ) Need Help??


in reply to Re: One for the regexp fans
in thread One for the regexp fans

Another common format for MAC address display is nnnn:nnnn:nnnn (common amongst Cisco gear, anyway).   In either case, it's the same 12 hex digits, only the delimiter and break-points change.

Is simple code that handles both formats possible?
    cheers,
    ybiC

  • Comment on RE: (2) One for the regexp fans (nnnn:nnnn:nnnn)

Replies are listed 'Best First'.
RE: RE: (2) One for the regexp fans (nnnn:nnnn:nnnn)
by nuance (Hermit) on Aug 04, 2000 at 17:19 UTC
    You could probably do something like:
    if $str =~ m!\.! {$str =~ s/(\.?[0-9a-eA-E]*)/(substr("0$1", -2))/ge;} else {$str =~ s/(:?[0-9a-eA-E]*)/(substr("0$1", -4))/ge;}

    Nuance

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://26166]
help
Chatterbox?
[choroba]: I don't even remember the beginning
[choroba]: someone told me to use perl instead of sed for something, and several years later, I'm developing a huge Tk application
[Discipulus]: choroba started in primary school to get some advantage in the future..
[choroba]: nono, I programmed in Basic at the primary school, on my Commodore 116/16
[Discipulus]: ;=)
[choroba]: then learned some assebly on the same machine, then moved to my father's PC (XT with a Hercules card), used Turbo Pascal a lot
[choroba]: I started with *nix at the University, we had some Sparcs and Linux machines
[choroba]: that was around 1994 or 95

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2018-06-22 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (123 votes). Check out past polls.

    Notices?