C# – icd9 regex pattern


I cannot find a definitive guide to icd9 code formats.

Can anyone explain the format – especially the use of trailing and leading zeros?

A C# regex for icd9 and icd10 codes would also be nice.


Best Solution

I was looking for the same thing and found what I believe to be a more complete answer. Thought I'd help anyone else coming in the future.

ICD-9 Regex

The ICD 9 format has a bunch of ways it can be formatted. It can begin with V, E, or a number.

  • If it begins with V, then it has 2 numbers, a decimal, then up to two numbers
    • Examples: V10.12 and V12
  • If it begins when E, then it has 3 numbers, the decimal place, then up to two numbers
    • Examples: E000.0 and E002
  • If it begins with a number, then it is up to 3 numbers, a decimal, then up to two numbers
    • Examples: 730.12 and 730

A good regex that checks all these rules is (Credit goes to sascomunitt)


ICD-10 Regex

According to www.cms.gov ICD-10 has the following rules:

  • 3-7 Characters
  • Character 1 is alpha (cannot be U)
  • Character 2 is numeric
  • Characters 3-7 are alphanumeric
  • After 3 characters you use a decimal
  • Use of dummy placeholder "x" (This is the only one I am not accounting for in my regex...)
  • Alpha characters are not case sensitive

Here is the regex I came up with:


Note These regexes are for javascript and may need tweaked for C# (I'm too lazy to test it right now)