#NEWLINE# def match_reg( self , reg ) : #NEWLINE# #INDENT# 'match the given regular expression object to the current text\n        position.\n\n        if a match occurs, update the current text and line position.\n\n        ' #NEWLINE# mp = self . match_position #NEWLINE# match = reg . match ( self . text , self . match_position ) #NEWLINE# if match : #NEWLINE# #INDENT# ( start , end ) = match . span ( ) #NEWLINE# if ( self == start ) : #NEWLINE# #INDENT# self . match_position = ( end + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . match_position = end #NEWLINE# #UNINDENT# self . matched_lineno = self . lineno #NEWLINE# lines = re . findall ( '\\n' , self . text [ mp : self . match_position ] ) #NEWLINE# cp = ( mp - 1 ) #NEWLINE# while ( ( cp >= 0 ) and ( cp < self . textlength ) and ( self . text [ cp ] != '\n' ) ) : #NEWLINE# #INDENT# cp -= 1 #NEWLINE# #UNINDENT# self . matched_charpos = ( mp - cp ) #NEWLINE# self . lineno += len ( lines ) #NEWLINE# #UNINDENT# return match