Solved

Pattern Match for MAC address

Posted on 2012-03-30
9
576 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
Comment Utility
is

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

more correct?
0
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
how about

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

Expert Comment

by:sdstuber
Comment Utility
I made the assumption you would want to match other hex delimited values ending with 'ess-Mident-Wireless'
0
 
LVL 6

Accepted Solution

by:
theKashyap earned 500 total points
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 6

Expert Comment

by:theKashyap
Comment Utility
@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
Comment Utility
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
Comment Utility
@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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now