Solved

Pattern Match for MAC address

Posted on 2012-03-30
9
603 Views
Last Modified: 2012-04-02
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
0
Comment
Question by:luchuanc
9 Comments
 
LVL 3

Expert Comment

by:nullsquid
ID: 37789082
is

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

more correct?
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37789096
how about

([0-9A-F]{2}[:-]){5}ess-Mident-Wireless
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37789101
I made the assumption you would want to match other hex delimited values ending with 'ess-Mident-Wireless'
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Accepted Solution

by:
theKashyap earned 500 total points
ID: 37789109
I don't think so (21 is missing altogether). Here is more readable version:

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

Open in new window


or even more readable:

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

Open in new window

0
 
LVL 6

Expert Comment

by:theKashyap
ID: 37789133
@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!
0
 
LVL 74

Expert Comment

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

will also match...

"8:ess-Mident-Wireless"
0
 
LVL 6

Expert Comment

by:theKashyap
ID: 37789157
@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
  ^^^^^^
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 37789176
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]
0
 

Author Comment

by:luchuanc
ID: 37796905
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
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CrossWord puzzle solve code 2 661
Maths Calculations 12 238
Using Two Hash Results to Confirm Changes to Source Data 4 222
Good Magazines technology related 4 117
This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question