#NEWLINE# def _replace_expand( self , m , repl ) : #NEWLINE# #INDENT# ' Helper function for expanding a regular expression\n            in the replace field, if needed. ' #NEWLINE# if self . engine . isre ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# new = m . expand ( new ) #NEWLINE# #UNINDENT# except re . error : #NEWLINE# #INDENT# self . engine . report_error ( repl , 'Invalid Replace Expression' ) #NEWLINE# new = None #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# new = repl #NEWLINE# #UNINDENT# return new