import re


def get_value_from_environment_string(environment_string,
                                      variable_pattern,
                                      default=None):
  """Return the first value matching the pattern from the environment string."""
  pattern = r'%s\s*=\s*(.*)' % variable_pattern
  match = re.search(pattern, environment_string)
  if not match:
    return default

  return match.group(1).strip()