Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^[a-zA-Z0-9]{3,8}-\d{1}$
/
gm

Description

Pattern to identify LOINC codes, derived from the description in LOINC.org (June 2024):-

LOINC codes have a fixed length field of 7 characters within the LOINC database. Current codes are from 3-7 characters long. If you are currently building a system to include LOINC codes, we advise allowing up to 10 characters (or at least 8 characters) to allow for further expansion. When the LOINC database contains 100,000 different LOINC records, the fixed length field will need to expand to 8 characters. The last digit of the LOINC code is a check digit and is always preceded by a hyphen (dash). The hyphen, as well as all the numbers, is part of the LOINC and must be included. The check digit is always a number form 0-9 and serves to help avoid errors in transcription of the code. Current licensing agreement for use of LOINC codes requires you to send the complete LOINC code.

Submitted by Richard Baxter - 5 months ago