Skip to content

Instantly share code, notes, and snippets.

@tlef
tlef / gist:4090fca664e400f42c8d
Created June 19, 2014 22:34
Date and time based Regex patterns
Pattern for dates and date ranges:
/\b((monday|tuesday|wednesday|thursday|friday|saturday|sunday|mon|tue|tues|wed|thu|thur|thurs|fri|sa|sat|su|sun|today|tomorrow|yesterday)|(((january|february|march|april|may|june|july|august|september|october|november|december|ja|jan|fe|feb|mar|ap|apr|jun|jul|au|aug|se|sep|sept|oc|oct|no|nov|de|dec)[ ]([0-3]?[0-9])(st|rd|nd|th)?)([ ]?(20)?([0-9][0-9]))?)(([-]|([ ]+(to|until|til)[ ]+)?)([0-3]?[0-9])(st|rd|nd|th)?)?)|((([3]?[0-1])|([0-2]?[0-9]))[.-\/](([3]?[0-1])|([0-2]?[0-9]))[.-\/]([1-2][0-9])?[0-9][0-9])\b/i
Pattern for times (12 and 24h):
/\b((0?[1-9]|1[0-2])(:?[0-5][0-9])?(am|pm))|(0?[1-9]|1[0-9]|2[0-3])(((h|:)[0-5][0-9])|h)\b/
Pattern for time ranges:
/\b(((((0?[1-9]|1[0-2])(:?[0-5][0-9])?(am|pm))|(0?[1-9]|1[0-9]|2[0-3])(((h|:)[0-5][0-9])|h))((([ ]+)?([-]|(to))([ ]+)?)(((0?[1-9]|1[0-2])(:?[0-5][0-9])?(am|pm)?)|(0?[1-9]|1[0-9]|2[0-3])(((h|:)?[0-5][0-9])|h)))?)|((((0?[1-9]|1[0-2])(:?[0-5][0-9])?(am|pm)?)|(0?[1-9]|1[0-9]|2[0-3])(((h|:)?[0-5][0-9])|h))((([ ]+)?([-]|(to))(

Keybase proof

I hereby claim:

  • I am tlef on github.
  • I am tlef (https://keybase.io/tlef) on keybase.
  • I have a public key whose fingerprint is B47A 6481 828B 6D73 B289 6798 80B1 90EC 1D85 D422

To claim this, I am signing this object: