def METHOD_NAME(regex: Union[str, re.Pattern[str]], text, flags=0):
  """Extracts all matches from a regular expression matched within 'text'.
  Extracts all matches from a regular expression matched within 'text'. Please
  note that this function will return a list of strings if regex does not
  contain any capturing groups, matching the behavior of re.findall:
  >>> re.findall(r'bar', 'foo foo bar foo bar foo')
  ['bar', 'bar']
  Args:
    regex: string. Regular expression.
    text: string. Text to search.
    flags: int. Flags to pass to re.findall().
  Returns:
    A list of tuples of strings that matched by 'regex' within 'text'.
  Raises:
    NoMatchError: when 'regex' does not match 'text'.
  """
  match = re.findall(regex, text, flags=flags)
  if not match:
    raise NoMatchError('No match for pattern "{0}" in "{1}"'.format(
        regex, text))
  return match