Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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?
[holli]: the fricking beast will only eat dry food
[holli]: nothing else, not even minced meat or fish
[Discipulus]: see you nuns and monks!
[KurtZ]: mice?
[Discipulus]: your cat is dryarian holli
[holli]: not even remotely KurtZ. i did find feathers in the garden a few times though
[holli]: yet no body
[virtualsue]: I was called upon to remove a gnawed mouse carcass from the living room this morning
holli googles dryarian just to make sure that isn't actually thing
[holli]: I mean, you never know, right?

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-11-21 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (300 votes). Check out past polls.

    Notices?