#NEWLINE# def regex( self , line , regex , error_type = ERROR , line_match = None , word_match = None , word_re = None ) : #NEWLINE# #INDENT# "\n        Mark a range of text that matches a regex.\n\n        line, error_type and word_re are the same as in range().\n\n        line_match may be a string pattern or a compiled regex.\n        If provided, it must have a named group called 'match' that\n        determines which part of the source line will be considered\n        for marking.\n\n        word_match may be a string pattern or a compiled regex.\n        If provided, it must have a named group called 'mark' that\n        determines which part of the source line will actually be marked.\n        Multiple portions of the source line may match.\n\n        " #NEWLINE# offset = 0 #NEWLINE# ( start , end ) = self . full_line ( line ) #NEWLINE# line_text = self . code [ start : end ] #NEWLINE# if line_match : #NEWLINE# #INDENT# match = re . match ( line_match , line_text ) #NEWLINE# if match : #NEWLINE# #INDENT# line_text = match . group ( 'match' ) #NEWLINE# offset = match . start ( 'match' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# it = re . finditer ( regex , line_text ) #NEWLINE# results = [ result . span ( 'mark' ) for result in it if ( ( word_match is None ) or ( result . group ( 'mark' ) == word_match ) ) ] #NEWLINE# for ( start , end ) in results : #NEWLINE# #INDENT# self . range ( line , ( start + offset ) , ( end - start ) , error_type = error_type )