def ExtractGroup(regex, text, group=1):
  """Extracts a float from a regular expression matched to 'text'.

  Args:
    regex: string or regexp pattern. Regular expression.
    text: string. Text to search.
    group: int. Group containing a floating point value. Use '0' for the whole
      string.
  Returns:
    A floating point number matched by 'regex' on 'text'.
  Raises:
    NoMatchError: when 'regex' does not match 'text'.
    IndexError: when 'group' is not present in the match.
  """
  match = re.search(regex, text)
  if not match:
    raise NoMatchError('No match for pattern "{0}" in "{1}"'.format(
        regex, text))

  try:
    return match.group(group)
  except __HOLE__:
    raise IndexError('No such group {0} in "{1}".'.format(group, regex))
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/regex_util.py/ExtractGroup