code: function toRegExp(pattern) {
    return new RegExp('^' + escape(pattern) + '$', 'i');
  
    function escape(x) {
      return x.replace(/(\W)/g, function(_, match) {
        return match === '*'?   '.*'
        :      /* otherwise */  '\\' + match;
      });
    }
  }
docs: :: String -> RegExp