Skip to content

Instantly share code, notes, and snippets.

@jprudent
Created July 4, 2015 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jprudent/ce1e06377784c88763d1 to your computer and use it in GitHub Desktop.
Save jprudent/ce1e06377784c88763d1 to your computer and use it in GitHub Desktop.
ISO 8601 duration regexp
(def duration-pattern #"^(?<sign>\+|-)?P(?:(?:(?:(?<years>\d+(?:[,.]\d+)?)Y)?(?:(?<months>\d+(?:[.,]\d+)?)M)?(?:(?<days>\d+(?:[.,]\d+)?)D)?(?<time>T(?:(?<hours>\d+(?:[.,]\d+)?)H)?(?:(?<minutes>\d+(?:[.,]\d+)?)M)?(?:(?<seconds>\d+(?:[.,]\d+)?)S)?)?)|(?<weeks>\d+(?:[.,]\d+)?W))$")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment