import re


def _safe_search(regex, haystack, options=0):
  """Searches for string, returns None if not found.

  Assumes that regex has on and only 1 group.
  Args:
    regex: regular expression to use with 1 group.
    haystack: the text to search (assumes multiline)
    options: regular expression options
  Returns:
    String or None
  """
  grps = re.search(regex, haystack, options)
  if not grps:
    return None
  return grps.group(1)