#NEWLINE# def _generate_pattern( self , text ) : #NEWLINE# #INDENT# "\n        Given a string, returns an regex pattern to match that string. \n        \n        'HTML' -> r'(?P<abbr>[H][T][M][L])' \n        \n        Note: we force each char as a literal match (in brackets) as we don't \n        know what they will be beforehand.\n\n        " #NEWLINE# chars = list ( text ) #NEWLINE# for i in range ( len ( chars ) ) : #NEWLINE# #INDENT# chars [ i ] = ( '[%s]' % chars [ i ] ) #NEWLINE# #UNINDENT# return ( '(?P<abbr>\\b%s\\b)' % '' . join ( chars ) )