Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created September 4, 2009 03:05
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 darkhelmet/180705 to your computer and use it in GitHub Desktop.
Save darkhelmet/180705 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
# this fails matching /2009/04/30/borland-c++-builder-5-how-i-hate-thee
get %r|^/\d{4}/\d{2}/\d{2}/[\w\d\-+]+$| do |match|
p match
end
#!/usr/bin/env ruby
link = '/2009/04/30/borland-c++-builder-5-how-i-hate-thee'
regex = %r|^/\d{4}/\d{2}/\d{2}/[\w\d\-+]+$|
# this works
p link =~ regex
p link.match(regex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment