Regular Expressions 101

Community Patterns

Current Procedural Terminology (CPT) codes


Regular Expression
PCRE2 (PHP >=7.3)



CPT is a uniform coding system consisting of descriptive terms and identifying codes used primarily to identify medical services and procedures furnished by physicians and other health care professionals for which they bill public or private health insurance programs. It is a numeric coding system maintained by the American Medical Association (AMA).

CPT codes can be subdivided into 3 levels/categories (not to be confused with HCPCS Level II!):

  • Category I: Evaluation & Management Services, Anesthesia, Surgery, Radiology, Procedures, Pathology & Laboratory Procedures, and Medicine Services & Procedures. All 5 characters are numeric.
  • Category II: Optional, but provide extra information about additional procedures typically performed with Category I CPT Codes, for example 3008F is “Body Mass Index (BMI) documented” which occurs during the Evaluation & Management Services. First 4 digits numeric, followed by an “F”.
  • Category III: Describe emergent or experimental services that help providers and government agencies track efficacy of those medical techniques. They may become Category I but have an expiration of 5 years. First 4 digits are numeric, followed by any other letter. This regex does not match codes with optional modifiers:- "A medical coding modifier is two characters (letters or numbers) appended to a CPT® or HCPCS Level II code. The modifier provides additional information about the medical procedure, service, or supply involved without changing the meaning of the code. Medical coders use modifiers to tell the story of a particular encounter." ( There is another pattern in regex101 that does match codes with optional modifiers
Submitted by Richard Baxter - a month ago (Last modified a month ago)