Link to home
Start Free TrialLog in
Avatar of luchuanc
luchuancFlag for United States of America

asked on

Pattern Match for MAC address

Hi

I have 2 strings:
  00-0F-B7-21-22-44:ess-Mident-Wireless
  00:0F:B7:21:20:A8:ess-Mident-Wireless

How to create a pattern match for them using the rules in: http://technet.microsoft.com/en-us/library/cc755272(WS.10).aspx

Is the following correct?
00\-|\:0F\-|\:B7\-|\:22|0\-|\:4|8:ess-Mident-Wireless

Thanks,

Luchuan
 

Thanks,

Luchuan
Avatar of nullsquid
nullsquid

is

00\-|\:0F\-|\:B7\-|\:21\-|\:22|0\-|\:4|A4|8:ess-Mident-Wireless

more correct?
Avatar of Sean Stuber
how about

([0-9A-F]{2}[:-]){5}ess-Mident-Wireless
I made the assumption you would want to match other hex delimited values ending with 'ess-Mident-Wireless'
ASKER CERTIFIED SOLUTION
Avatar of theKashyap
theKashyap

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@nullsquid though this NPS regEx syntax is new to me, just thinking abt any regEx engine impl, i wonder how the matcher would figure out the LHS and RHS of an or statement without bounds.

E.g. according to my understanding
00\-|\:0F\-|\:B7\-|\:21\-|\:22|0\-|\:4|A4|8:ess-Mident-Wireless

would match "00-" as well!
00\-|\:0F\-|\:B7\-|\:21\-|\:22|0\-|\:4|A4|8:ess-Mident-Wireless

will also match...

"8:ess-Mident-Wireless"
@sdstuber however stupid this sounds, http://technet.microsoft.com/en-us/library/cc755272%28WS.10%29.aspx doesn't list ranged expressions ([0-9]) as supported!

([0-9A-F]{2}[:-]){5}ess-Mident-Wireless
  ^^^^^^
it doesn't in the character list column but it uses them in the examples so I made the assumption they were supported

For example:

\d   Matches a digit character (equivalent to [0-9]).

if they really aren't supported though (yuck) then change

[0-9A-F]

to

[0123456789ABCDEF]
Avatar of luchuanc

ASKER

In trying to get these to work I found there is a bug in Windows NPS:

http://support.microsoft.com/kb/2599437

Things only worked after I applied this hotfix.

I also noticed I had incorrectly posted the MACs - both use a "-" as separator not ":"

final code:

00-0F-B7-21-22-44:ess-Mident-Wireless
00-0F-B7-21-20-A8:ess-Mident-Wireless

00[-]0F[-]B7[-]21[-](20|22)[-](44|A8):ess-Mident-Wireless