function wildcardToRegExp(s) {
  return new RegExp('^' + s.split(/\*+/).map(regExpEscape).join('.*') + '$');
}
Creates a RegExp from the given string, converting asterisks to .* expressions,
and escaping all other characters.