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