RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find DoD CAC Common Name
Expression
^\s*(?<Last>[-A-Za-z ]+)[.](?<First>[-A-Za-z ]+)(?:[.](?<Middle>[-A-Za-z ]+))?(?:[.](?<Ordinal>[IVX]+))?(?:[.](?<Number>\d{10}))\s*$
Description
Matches the Common Name (CN) of the subject of a US Department of Defense (DoD) Common Access Card (CAC). In the plain-text part of the client certificate stored on a CAC, a subject, or the person named as the user of the certificate is represented by their Common Name. This regex identifies CNs and groups the parts that represent first and last name and the unique 10-digit identifying number at the end. I optionally matches the middle name or initial and ordinal (or generation) (II,III,IV, etc), if present. It also accounts for both leading and trailing spaces as well as spaces and dashes within the name parts. It works for all common names I have ever had to deal with, though I do not know where the standard is stated to confirm compliance. It is formatted for use specifically as validation, but could be modified for search.
Matches
SMITH.JOHN.Q.0123456789 | SMITH.JANE.9876543210 | FILCH-TEMPLETON.GEORGE.FILIGREE-WHITE.XXVII.0192837465
Non-Matches
JOHN.1234567890 | SMITH.HENRY.123 | A.B.C.D.5647382910
Author Rating: The rating for this expression. Brett Peirce
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials