Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Regular Expression for MAC Address

by jrynz (Initiate)
on May 20, 2007 at 02:12 UTC ( #616378=note: print w/ replies, xml ) Need Help??

in reply to Regular Expression for MAC Address

Try this one:
Example Usage (extract MAC address):

my $string = 'tu0 1500 <Link> 00-00-f8-05-c8-20'; $string =~ m/^.+ ( # Start back reference capture for MAC Address ((?:(\d{1,2}|[a-fA-F]{1,2}){2})(?::|-*)){6} ) # End back reference $/xms; print "$1\n" if (defined $1);
NB: This will also work with MAC like:
my $string = 'tu0   1500  <Link>  00:00:f8:05:c8:20';

Comment on Re: Regular Expression for MAC Address
Select or Download Code
Replies are listed 'Best First'.
Re^2: Regular Expression for MAC Address
by Anonymous Monk on Mar 24, 2011 at 17:10 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://616378]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-11-26 16:32 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (703 votes), past polls