import re


def _translate(pat):
  """Given a pattern, returns a regexp string for it."""
  out = '^'
  for c in pat:
    if c == '*':
      out += '.*'
    else:
      out += re.escape(c)
  out += '$'
  return out