import re


def re_with_default(pattern, string, default=None):
  """Finds a regex match and returns a default value of no match is found."""
  match = re.search(pattern, string)
  if match:
    return match.group()
  else:
    return default