bre.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:backrefs 作者: facelessuser 项目源码 文件源码
def iternext(self):
        """
        Iterate through characters of the string.

        Count escaped l, L, c, C, E, N, p, P, backslash as a single char.
        """

        if self.index > self.max_index:
            raise StopIteration

        char = self.string[self.index:self.index + 1]
        if char == self._b_slash:
            m = self._re_search_ref.match(self.string[self.index + 1:])
            if m:
                ref = m.group(0)
                if len(ref) == 1 and ref in self._long_search_refs:
                    if ref == self._unicode_name:
                        raise SyntaxError('Format for Unicode name is \\N{name}!')
                    elif ref == self._uni_prop:
                        raise SyntaxError('Format for Unicode property is \\p{property}!')
                    elif ref == self._inverse_uni_prop:
                        raise SyntaxError('Format for inverse Unicode property is \\P{property}!')
                char += m.group(1) if m.group(1) else m.group(2)
        elif char == self._ls_bracket:
            m = self._re_posix.match(self.string[self.index:])
            if m:
                char = m.group(0)

        self.index += len(char)
        self.current = char
        return self.current


# Templates
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号