from typing import Optional
import re
import logging


def Prompt(message: str, validator: str = '.*') -> Optional[str]:
  """Prompt the user for input.

  Args:
    message: the prompt message displayed to the user
    validator: a regular expression to validate any responses

  Returns:
    a response string if successful, else None
  """
  response = input(message)
  if not re.match(validator, response):
    logging.error('Invalid response entered.')
    return None
  return response