Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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';

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 surveying the Monastery: (9)
As of 2016-10-25 22:30 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (330 votes). Check out past polls.