Skip to content

Instantly share code, notes, and snippets.

@atnan
Created February 17, 2010 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save atnan/306322 to your computer and use it in GitHub Desktop.
Save atnan/306322 to your computer and use it in GitHub Desktop.
pattern = begin
delimeter = "[-/.]+"
century_prefix = "(?:19|20)"
under_ten = "(?:0[1-9]+)"
ten_to_twelve = "(?:1[012]+)"
ten_and_under_thirty = "(?:[12]+[0-9]+)"
thirties = "(?:3[01]+)"
year = "(#{century_prefix}[0-9]{2})"
month = "(#{under_ten}|#{ten_to_twelve})"
day = "(#{under_ten}|#{ten_and_under_thirty}|#{thirties})"
/#{year}#{delimeter}#{month}#{delimeter}#{day}/
end
if pattern =~ "2010-02-17"
year, month, day = $1, $2, $3
# Insert multi-million dollar idea here
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment