#NEWLINE# @ property #NEWLINE# def regex( self ) : #NEWLINE# #INDENT# '\n        Return a compiled regular expression based on the activate language.\n        ' #NEWLINE# language_code = get_language ( ) #NEWLINE# if ( language_code not in self . _regex_dict ) : #NEWLINE# #INDENT# regex = ( self . _regex if isinstance ( self . _regex , six . string_types ) else force_text ( self . _regex ) ) #NEWLINE# try : #NEWLINE# #INDENT# compiled_regex = re . compile ( compiled_regex , re . UNICODE ) #NEWLINE# #UNINDENT# except re . error as e : #NEWLINE# #INDENT# raise ImproperlyConfigured ( ( '"%s" is not a valid regular expression: %s' % ( regex , six . text_type ( e ) ) ) ) #NEWLINE# #UNINDENT# self . _regex_dict [ language_code ] = compiled_regex #NEWLINE# #UNINDENT# return self . _regex_dict [ language_code ]