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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details 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
   Displaying page 1 of 1 pages; Items 1 to 1

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