Solved

Pattern Match for MAC address

Posted on 2012-03-30
9
594 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 73

Expert Comment

by:sdstuber
ID: 37789096
how about

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

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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 73

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 73

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

785 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