(self, redundant_char)
生成 redundant_char 的正则 pattern
生成 redundant_char 的正则 pattern
生成 redundant_char 的正则 pattern
def _gen_redundant_char_ptn(self, redundant_char):
        """ 生成 redundant_char 的正则 pattern """
        pattern_list = []
        for char in redundant_char:
            pattern_tmp = '(?<={char}){char}+'.format(char=re.escape(char))
            # pattern_tmp = re.escape(char) + '{2,}'
            pattern_list.append(pattern_tmp)
        pattern = '|'.join(pattern_list)
        self.redundant_char_ptn = re.compile(pattern)
def _gen_redundant_char_ptn ( self , redundant_char ) : pattern_list = [ ] for char in redundant_char : pattern_tmp = '(?<={char}){char}+' . format ( char = re . escape ( char ) ) # pattern_tmp = re.escape(char) + '{2,}' pattern_list . append ( pattern_tmp ) pattern = '|' . join ( pattern_list ) self . redundant_char_ptn = re . compile ( pattern )