Skip to content

Instantly share code, notes, and snippets.

@jaime-olivares
Created June 19, 2019 18:34
Show Gist options
  • Save jaime-olivares/958cc70ada481b4e2498fdb327226932 to your computer and use it in GitHub Desktop.
Save jaime-olivares/958cc70ada481b4e2498fdb327226932 to your computer and use it in GitHub Desktop.
Regex expression for HL7 date according to http://www.hl7.eu/refactored/dtDTM.html
^((?:19|20)[0-9]{2})(?:(1[0-2]|0[1-9])(?:(3[0-1]|[1-2][0-9]|0[1-9])(?:([0-1][0-9]|2[0-3])(?:([0-5][0-9])(?:([0-5][0-9](?:\.[0-9]{1,4})?)?)?)?)?)?)?([+-](?:[0-1][0-9]|2[0-3])[0-5][0-9])?$
@jaime-olivares
Copy link
Author

This regex attempts to fully comply with the HL7 specification.
The pattern analyzed is: YYYY[MM[DD[HH[MM[SS[.S[S[S[S]]]]]]]]][+/-ZZZZ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment