     # Return the current value for window.location.hash without any
     # leading hash keys (does not remove leading slashes!).
     getHash: (url = location.hash) ->
-        url.replace(/^[^#]*#+(.*)$/, '$1')
+        url.replace(@RegExpCache.extractHash, '$1')
     
     # Takes whatever window.location.hash currently is and tries
     # to resolves that hash.

class Route
    
    # Cache some static regular expressions - thanks Backbone.js!
    escapeRegExp: /[-[\]{}()+?.,\\^$|#\s]/g
    namedParam: /:\w+/g
    splatParam: /\*\w*/g
    firstParam: /(:\w+)|(\*\w*)/
    
    constructor: (@pattern) ->
        if pattern instanceof RegExp

                # Do some escaping and replace the parameter placeholders
                # with the proper regular expression
                pattern = String(pattern)
                pattern = pattern.replace(@RegExpCache.escapeRegExp, '\\$&')
                pattern = pattern.replace(@RegExpCache.namedParam, '([^\/]+)')
                pattern = pattern.replace(@RegExpCache.splatParam, '(.*?)')
                
                @expr = new RegExp('^' + pattern + '$')
            else
