Skip to content

Instantly share code, notes, and snippets.

@j-brn
Last active January 17, 2019 12:39
Show Gist options
  • Select an option

  • Save j-brn/5b703c6461b414d079b7ce440fd36768 to your computer and use it in GitHub Desktop.

Select an option

Save j-brn/5b703c6461b414d079b7ce440fd36768 to your computer and use it in GitHub Desktop.

Useful regular expressions

This gist contains some useful regular expressions i wrote.

DateTime

With named capturing groups

^(?P<year>\d{4})\-(?P<month>0\d|1[0-2])\-(?P<day>0[1-9]|[12]\d|3[01])\s(?P<hour>2[0-3]|[01]\d):(?P<minute>5[0-9]|[0-4]\d):(?P<second>5[0-9]|[0-4]\d)$

Without named capturing groups

^(\d{4})\-(0\d|1[0-2])\-(0[1-9]|[12]\d|3[01])\s(2[0-3]|[01]\d):(5[0-9]|[0-4]\d):(5[0-9]|[0-4]\d)$

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